Repentless
New Member
I am looping through a list of Java Strings using JSP and generating HTML checkboxes for each String like so:\[code\]<%while (st.hasMoreTokens()){ String object = st.nextToken(); String temp = "<li><input type=\"checkbox\" id=\"" + object + "\" + name=\"type\" value =http://stackoverflow.com/"" + object + "\">" + object + "</li>"; out.println(temp);}%>\[/code\]However, because there are around 100 checkboxes, it would be time-consuming selecting ~40 options that the user wants to select. Instead, I'd like to create a drop-down menu that has custom hard-coded lists that would select the appropriate checkboxes. For example, if I had a list of checkboxes as follows:\[code\]AppleOrangeBananaPepperLimeLemonPeas\[/code\]I could create custom lists like the following:\[code\]var fruit={Apple, Orange, Banana, Lime, Lemon}var veg="{Pepper, Peas}\[/code\]Then, I could create a drop-down with "Fruits" and "Vegetables" as the only two options. If the user selects "Fruits," then JavaScript would check "Apple", "Orange", "Banana", "Lime", and "Lemon", and vice versa.It's important that the user should still be able to select one or a few checkboxes manually, so the huge list of checkboxes is essential.