By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,428 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,428 IT Pros & Developers. It's quick & easy.

Unchecking specified checkboxes in a table

P: 2
I have a table with 12 checkboxes. I have the following function which when I check the last checkbox in the table, the first 10 checkboxes in the table are unchecked. -

function modify_boxes(to_be_checked,total_boxes){ for ( i=0 ; i < total_boxes ; i++ ){ if (to_be_checked){ document.forms[0].x[i].checked=true; } else{ document.forms[0].x[i].checked=false; } } }

I have the following in 'onclick' on the last checkbox in the table -


What I would like to happen, is when the first checkbox in the table is checked, that only the last two checkboxes in the table are unchecked. However the names of the checkboxes must all be 'x' as they are referenced elsewhere

thanks in advance
Mar 6 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 15k+
P: 16,027
Geovanni, welcome to The Scripts.

Just use the same method, onclick and call a function:
Expand|Select|Wrap|Line Numbers
  1. function modifyLastTwo(checked) {
  2. var len = document.forms[0].x.length;
  3. document.forms[0].x[len-2].checked=checked;
  4. document.forms[0].x[len-1].checked=checked;
  5. }
with checked being either true or false, depending on the value of the first checkbox.
Mar 6 '07 #2

P: 2
thanks a lot
Mar 6 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.