Reputation: 7035
HI Guys,
I am trying to hide a value in my html select. Its working fine in Firefox bit not is IE.
Below the the troubling line. Please advice
var searchAttributeEnum =
{
ProductID: 1,
PublisherProductID: 2,
Artist: 3,
Title: 4,
Publisher: 5,
ProductType: 6
};
$(this).parents('div.cloneRow').find(".js-CellSecond option[value='" + searchOptionsEnum.StartsWith + "']").hide();
HTML
<div class="cloneRow">
<div class="col">
<uc1:Dropdown ID="searchKey" CssClasses="js-CellFirst" runat="server" />
</div>
<div class="col">
<uc1:Dropdown ID="searchType" CssClasses="js-CellSecond" runat="server" />
</div>
<div class="col">
<input type="text" value="" class="searchText js-CellThree" name="searchInput" />
<uc1:Dropdown ID="searchPublisherType" CssClasses="js-CellThreePublisher" runat="server" />
<uc1:Dropdown ID="searchProductType" CssClasses="js-CellThreeProductType" runat="server" />
</div>
</div>
Thanks
Upvotes: 0
Views: 168
Reputation: 3172
You should re-build the select from scratch every time when the element list changes. It's sounds bad, but it's quite fast (even under MSIE).
(Then you have to deal with the problem: which element will be the new selected, when the actual one gets removed? When it appears again (and the user hasn't selected another one), how could you manage to make the re-appearing item selected again?)
Upvotes: 0
Reputation: 3257
Said Mark
Hiding options is not cross-browser compatible.
Here you can find you answer
Upvotes: 0
Reputation: 30135
Had that problem too a while ago.
The conclusion: IE just can't hide individual options in a select. (I think Opera too but not sure)
Possible solution: Delete the option completely but keep all the options in a hidden second select (or array) so you could re-add them later.
Upvotes: 1