Solved

style="display:none" does not work for option element

Posted on 2007-12-04
4
5,730 Views
Last Modified: 2009-04-11
Hello
I have a select list and I need a way to set certain option tags invisible. I tried applying style="display:none" to the option tags but this has had no effect.
The reason for this is that I am going to use some JavaScript to dynamically enable some selections in the drop down list.
Please see the attached code snippet.
Thanks

<select id="counties" tabindex="1">

 <option value="">Select</option>

 <option style="display:none" value="IE76176089">Carlow</option>

 <option style="display:none" value="IE96268862">Cavan</option>

 <option style="display:none" value="IE55624026">Clare</option>

 <option style="display:none" value="GB55624026">London</option>

 <option style="display:none" value="GB55624026">Surrey</option>

</select>

Open in new window

0
Comment
Question by:mike99c
  • 2
4 Comments
 
LVL 19

Assisted Solution

by:SteveH_UK
SteveH_UK earned 166 total points
ID: 20402555
0
 
LVL 19

Accepted Solution

by:
erikTsomik earned 167 total points
ID: 20402757
0
 
LVL 29

Assisted Solution

by:Göran Andersson
Göran Andersson earned 167 total points
ID: 20413381
You can't hide options, you have to remove them from the select list if you don't want them to show up.

Here is how you dynamically add an option to the select list:

var o = document.createElement('option');
o.value = 'IE76176089';
o.text = 'Carlow';
document.getElementById('counties').options.Add(o);
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20548658
Checking back to see if you had any progress?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now