Previous Example-|-Next Example-|-Return to Chapter Listing
Example 7.9:
Call By Value
This example is the same as 7-8, except that the function, Percentage, sets both of its arguments (sNum and sPerc), to 0 after it has performed the calculation. This has no effect on the numbers that are displayed and shows that the values passed into a function can be changed inside the function but this has no effect on the values outside of the function. (If you didn't type numbers into the Prompt box, you will have seen an error--we haven't done any error checking in this script.)
Click on these buttons to view the values held by nValue1 and nValue2:
These are the scripts we used. First, in the HEAD:
Later in the Web page the function is called by this script:
And we created these buttons:
Previous Example-|-Next Example-|-Return to Chapter Listing