• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Check/Uncheck All

 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want a code to provide a facility to check/uncheck all checkboxes of the same table.

I also want if the checkbox is disabled, then it shud not respond to the action. I've following code for doing this :-


This code is working fine. Only problem with this is... since I'm checking checkboxes, it will check all the boxes in the same form. I just want to check boxes belong to the same table or section.

Help me in solving this.....
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try somcething like this:

arrElem = document.getElementById("theTable").getElementsByTagName("input");
for(i=0;i<arrElem.length;i++){
if(arrElem[i].type.toLowerCase()=="checkbox")arrElem[i].checked=!(document.FormName.C0.checked)
}

Eric
 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx for ur reply.

I am not very much familiar with Javascript. So it will help if you elaborate more on this.

I need to write a function in Javascript for following specs:

1) Check/Uncheck all checkboxes on click of checkbox in the header.
2) The checkbox in the header shud be unchecked, if any of the checkboxes
is deslected.
3) If any of the checkbox is disabled, it shud not be checked.
4) It shud function as mentioned above even if there is just one row of checkbox in the table

The function i've pasted above is catering all the needs, except one issue with this func. If i've check box anywhere else on the page not belonging to the table, then also it is getting checked.

Pls help me in solving this problem.

TIA

Grishma.
[ June 23, 2005: Message edited by: Grishma Dube ]
reply
    Bookmark Topic Watch Topic
  • New Topic