View Single Post
Old 04-25-2009, 11:27 PM   #22 (permalink)
allworknoplay
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Ok, what am I doing wrong here? I want to count the checkbox and increment, if you uncheck, it should decrement.


My checkboxes are in a form named: form2
The checkboxes are named: checkbox

Code:
function checkbox_stat() {

if(document.form2.checkbox.checked == true)   ++document.getElementById('select_chks').innerHTML;	      

else --document.getElementById('select_chks').innerHTML;
	
}
I have a SPAN ID called: select_chks that displays the number of checkboxes selected.

And when you click on a checkbox, it calls the function above:

onClick="checkbox_stat(this);"


What I am getting is negative numbers like -1, -2, -3...

Which means that the first conditional isn't working and it's resorting to the else condition....which of course, decrements...

But why is this not working?

if(document.form2.checkbox.checked == true)
allworknoplay is offline  
Reply With Quote