Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summing the values of multiple checkboxes with same name. (with code)

Status
Not open for further replies.

bladergames

Programmer
Jun 23, 2001
4
US
I have 4 checkboxes. I want to sum their values together
All I can get is the values listing out, not adding up!

If they check 1 and 3, I'm getting a IntCat value of 13, not 4!!!! I will be more than happy to explain more, but I think this one is easy.

Page 1
Type=CheckBox Name=Category value="1" Checked>Process
Type=CheckBox Name=Category value="2" Checked>Equipment Type=CheckBox Name=Category value="4" >&nbsp New Model
Type=CheckBox Name=Category value="8" >&nbsp Other

Page2
For J=1 to Request.QueryString("category").Count
IntCat = IntCat + Request.QueryString("category")(J)
Next

i want my intcat to sum the values. It gives me a 13, not 4. I thought this was how to add them up! Thanks!!!
 
In JavaScript, there are a few properties of the
Code:
window
that return numbers based on a String input.

Code:
parseInt("5.3");    // returns an integer: 5
parseFloat("5.3");  // returns a float: 5.3
Number("5.3");      // returns a float: 5.3

The
Code:
parseInt()
and
Code:
parseFloat()
functions do more parsing through the string than the
Code:
Number()
function. If you pass a variable that is not a number, the
Code:
Number()
function returns
Code:
NaN
, while the other two functions will be more persistant in finding a number.
bluebrain.gif
blueuniment.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top