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

Example 5.4:
Dividing


Click this button to see the value in the nPricePerPerson variable, the result of dividing numbers:


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