Points Distribution Script
3. Calling the Script
Join the Discussion
More of this Feature
Now that we have set up the script and attached it to our web page, all that remains is to put the necessary fields into our form and set them up to work with the script.
The first field we need to add to our form is one to display the number of points that are remaining. The code for this field looks like this:
This field must be named remain to work with the script and it should be assigned the same value as you gave maxpts or it will look a bit strange when the points are adjusted when the first option is selected.
We also need to add the check boxes for the individual options that are available to be selected. Each of these should be coded similarly like this:
These fields need to be named opt0, opt1, opt2, etc. with the number of points required to select the options being the same as the respective value assigned to pt[selbx++] (the array entries start from 0).
The actual script functioning is called from the onchange event code and the name associated with the form needs to be passed as the first parameter.
With these codings in place, whenever any of the check boxes is checked or unchecked the total number of points for all of the checked boxes will be recalculated by the script and if insufficient points are available then the last box checked will be unchecked again and the 'insufficient points' message displayed.

