• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic