• 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

How to get a checkbox list using javascript?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks!

I'm developing a web application and there is an html form which contains a table with four columns. At the first column, I put checkboxes which allow the user remove the items specified on the second column. Moreover, each item may contain more than one subitem. So, at the third column I put checkboxes which allow the user remove the subitems specified on the forth column.

The first column checkboxes are named as "removeItem".
The third column checkboxes are names as "removeItem" + index of the item + "SubItem".

If the user check the checkbox of the first column, all subitems checkboxes related with the selected checkbox item must be checked.

The problem is that I don't know how to obtain the checkboxes of the third column when the first column checkbox is checked.

Someonde knows an solution for this problem?

Thanks!
Jo�o Cunha

PS:
I writed an javascript using the document.getElement() method, but it didn't wotk. It follows the code:

function selectItem(itemIndex) {
var items = document.teamForm.removeItem;
var subItems = document.getElementById("removeItem" + itemIndex + "SubItem");
if (items.length > 0) {
if (teamMember[teamMemberIndex].checked) {
checkAll(teamMemberRoles);
}
else {
clearAll(teamMemberRoles);
}
}
else {
if (teamMember.checked) {
checkAll(teamMemberRoles);
}
else {
clearAll(teamMemberRoles);
}
}
}

The methods checkAll and clearAll check and uncheck, respectively, all the checkboxes from a list
 
reply
    Bookmark Topic Watch Topic
  • New Topic