1. Home
  2. Computing & Technology
  3. JavaScript

Points Distribution Script

2. Adding the Script

Join the Discussion

Questions? Comments?

More of this Feature

What it Does Calling the Script

The first step in using this script is to select the code from the text box below (there is a highlight all button beneath it to make this easier) and copy it into a file called sel.js.

The lines at the bottom of the script will need to be changed to match your particular points distribution requirements. The maxpts value should match the number of points that you are making available to be distributed (in my example there are 50 points available). Each pt[selbx++] value should be set to the number of points required for each of the available options to be selected in the order that they are going to be numbered in the form (in the example the options cost 5, 15, 35, and 30 points respectively).

You attach this updated script into your web page that that needs to perform the points distribution validation by adding the following code into the head section of your page.

<script type="text/javascript" src="sel.js">
</script>

Next we will look at the coding of the script and how to call the script in order to get it to detrermine whether enough points remain to allow the latest option to be selected.

What it Does | Adding the Script | Calling the Script
Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.