T
TKapler
I think i am quite experienced javascript programmer, but I got a
problem.
I have a selectbox with e.g. 17 optgroups with 100 options.
I need a javascript code to hide some of that optgroups (i can give
each optgroup individual ID, e.g. id="group1"..."group"17).
e.g. the html code looks like:
<select name="mySelect" id="mySelect">
<optgroup label="First group" id="group1" >
<option value="a" >
Item A
</option>
<option value="b" >
Item B
</option>
</optgroup>
<optgroup label="Second group" id="group2" >
<option value="a" >
Item A
</option>
<option value="b" >
Item B
</option>
</optgroup>
</select>
The problem is, that no code i was able in last 3 hours invent works. I
tried e.g.
document.getElementById("group1").className="hidden"; //style .hidden
{display:none}
document.getElementById("group1").style.display=none;
and many other variants. I can easily hide this way the whole select,
in FF i can hide also option, but i can never hide the whole group.
If this is a "feature" and there is no sollution, you may help me to
find something different - i need javascript code to move one whole
optgroup to the beggining of the list. Or (this may be the sollution
for the first problem): get one group and make a new selectbox just
after the first one (and then i would hide the first).
P.S.: i do not want ajax lists, just some easy client side sollution
problem.
I have a selectbox with e.g. 17 optgroups with 100 options.
I need a javascript code to hide some of that optgroups (i can give
each optgroup individual ID, e.g. id="group1"..."group"17).
e.g. the html code looks like:
<select name="mySelect" id="mySelect">
<optgroup label="First group" id="group1" >
<option value="a" >
Item A
</option>
<option value="b" >
Item B
</option>
</optgroup>
<optgroup label="Second group" id="group2" >
<option value="a" >
Item A
</option>
<option value="b" >
Item B
</option>
</optgroup>
</select>
The problem is, that no code i was able in last 3 hours invent works. I
tried e.g.
document.getElementById("group1").className="hidden"; //style .hidden
{display:none}
document.getElementById("group1").style.display=none;
and many other variants. I can easily hide this way the whole select,
in FF i can hide also option, but i can never hide the whole group.
If this is a "feature" and there is no sollution, you may help me to
find something different - i need javascript code to move one whole
optgroup to the beggining of the list. Or (this may be the sollution
for the first problem): get one group and make a new selectbox just
after the first one (and then i would hide the first).
P.S.: i do not want ajax lists, just some easy client side sollution