Previous Example-|-Next Example-|-Return to Chapter Listing

Example 5.2:
Subtracting


Click this button to see the value in the nProfit variable, the result of subtracting one number from another:


This is the script we used. First we placed this in the HEAD: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- var nProfit = 0 var nPrice = 99 var nCosts = 47 nProfit = nPrice - nCosts //--> </SCRIPT> Then we created this button: <form> <input type="button" name="VariableButton" value="The result of the calculation" onclick="alert(nProfit)"> </form>
Previous Example-|-Next Example-|-Return to Chapter Listing