469,336 Members | 5,695 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Unchecking specified checkboxes in a table

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 -

modify_boxes(false,10)

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
2 1486
acoder
16,027 Expert Mod 8TB
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
thanks a lot
Mar 6 '07 #3

Post your reply

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

Similar topics

1 post views Thread by Lumpierbritches | last post: by
1 post views Thread by TechnoAtif | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.