469,275 Members | 1,802 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Hiding OPTIONS in SELECT ?

Using IE5.5+, is it possible to hide options in a select?

The following doesn't work:

<HTML>
<HEAD>
<STYLE>
SELECT OPTION.orgA{ display:none }
.orgB{ display:inline }
.orgC{ display:none }
</STYLE>
</HEAD>
<BODY>
<SELECT id=cbo size=3>
<OPTION class="orgA">RTI</OPTION>
<OPTION class="orgB">LAB</OPTION>
<OPTION class="orgC">TCI</OPTION>
</SELECT>
</BODY>
</HTML>

Best Regards,
Jesse Wade
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
1 6468
"comp.lang.javascript" wrote:
Using IE5.5+, is it possible to hide options in a select?

The following doesn't work:

<HTML>
<HEAD>
<STYLE>
SELECT OPTION.orgA{ display:none }
.orgB{ display:inline }
.orgC{ display:none }
</STYLE>
</HEAD>
<BODY>
<SELECT id=cbo size=3>
<OPTION class="orgA">RTI</OPTION>
<OPTION class="orgB">LAB</OPTION>
<OPTION class="orgC">TCI</OPTION>
</SELECT>
</BODY>
</HTML>

Best Regards,
Jesse Wade


If you want to have items dynamically appear and disappear from a
<select> you're going to have to remove the references to the
actual <option> objects and recreate them when you want them
"visible":

document.getElementById{'cbo').options[1] = null;
var select = document.getElementById('cbo');
select.options[select.option.length] = new Option(...);

Of course that adds it to the bottom, if you want it added at the
cursor position or in sorted order, you'll have to re-order the
<option> objects after you add the new ones.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available
at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by c.anandkumar | last post: by
3 posts views Thread by Frank K. | last post: by
1 post views Thread by roland-d | last post: by
1 post views Thread by Malinmore | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.