mtran
01-22-2010, 06:36 AM
Hi,
I have a bunch of checkboxes with id from 301 to 400. Originally there're no gaps in between 301 to 400, so my for loop ran ok. Now there're lots of gaps and the code below doesn't work as wanted. It only works for the first couple of ids then stop at the first gap. For example, if 304 is missing, the loop will only work for 301, 302, 303; 305 and the rest won't be changed.
How do I force the for loop to run from 301 through 400? Thanks!
for (a = 301; a<401; a++){
document.getElementById(a).checked = false; }
I have a bunch of checkboxes with id from 301 to 400. Originally there're no gaps in between 301 to 400, so my for loop ran ok. Now there're lots of gaps and the code below doesn't work as wanted. It only works for the first couple of ids then stop at the first gap. For example, if 304 is missing, the loop will only work for 301, 302, 303; 305 and the rest won't be changed.
How do I force the for loop to run from 301 through 400? Thanks!
for (a = 301; a<401; a++){
document.getElementById(a).checked = false; }