• 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

Drop down box selection

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to create a functionality in which if you select a user role from a dropdown box then it should populate large amounts of check boxes.

Actually, it is a web page where you assign a new user his permissions in the portal. It is a very long list of check boxex and it takes really long to complete it.

Now what I have to do is that if we select any user role from a dropdown list(any other option is also open) then it should auto populate the checkboxes defined for that role.

Any ideas how this can be done?
 
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 would just have to add an onchange event handler to the select element. You would then need a swicth stamenet of if statements that would set the checkboxes for that role.

document.formName.elementName.checked = true;

you could just create an array and loop through it to set the elements:
document.formName.elements[yourArray[i]].checked = true;

Eric
 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am just expanding what Eric has mentioned !!

// LOOP THROUGH EVERY FIELD IN THE FORM
for (count = 0; count < document.formname.length; count++) {

// GET CURRENT ELEMENT
var element = document.formname.elements[count];
if (element.type == "checkbox") {
element.checked = true;
}
}

Hope this helps !!
 
Nee Kat
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot for the help!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic