File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Drop down box selection" Watch "Drop down box selection" New topic

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

Joined: Nov 08, 2001
Posts: 15385
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;

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
I am just expanding what Eric has mentioned !!

for (count = 0; count < document.formname.length; count++) {

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:
subject: Drop down box selection
It's not a secret anymore!