Konrad Viltersten
Konrad Viltersten

Reputation: 39190

Displaying of a subset of options in a select tag using classes

I've got two select tags and the contents of the first govern the contents of the second. At this point, it's resolved so that when a selection fires an even, the latter is repopulated with new values.

I'm thinking of populating it with all the items but only setting style to visible on the ones that correspond to the former's selection. However, I noticed that the following didn't affect the appearance.

return "<option"
  + " style='display: none;'"
  + " value=" + value
  + ">" + text + "</option>"

How can I achieve what I wish?

Upvotes: 1

Views: 197

Answers (1)

ScottS
ScottS

Reputation: 72261

Sometimes Many times IE just really stinks. So display: none; works fine in other browsers, but basically the only valid way to "hide" it in IE is to comment it out (which is cross browser). So you would need to have your code be:

return "<!--<option"
  + " style='display: none;'"
  + " value=" + value
  + ">" + text + "</option>-->"

However, then the question is, does that really help you at all? Or is it just better to populate the values on the fly as you were doing.

Upvotes: 1

Related Questions