aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Drop down box selection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Drop down box selection" Watch "Drop down box selection" New topic
Author

Drop down box selection

Nee Kat
Ranch Hand

Joined: Jan 27, 2004
Posts: 37
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?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
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 !!


SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Nee Kat
Ranch Hand

Joined: Jan 27, 2004
Posts: 37
Thanks alot for the help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drop down box selection