0

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

Amit
  • 6,839
  • 21
  • 56
  • 90
  • really it is hides value of option in FireFox? or you want to hide option of select? send your html and jquery please. and question: what is a searchOptionsEnum.StartsWith? where you have defined this enum? – AEMLoviji Apr 20 '11 at 07:22
  • Don't you think it would be a good idea to show us your HTML code, too? – ThiefMaster Apr 20 '11 at 07:25
  • updated issue added HTML – Amit Apr 20 '11 at 07:28

3 Answers3

1

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.

Andy
  • 29,707
  • 9
  • 41
  • 58
0

Said Mark

Hiding options is not cross-browser compatible.

Here you can find you answer

Community
  • 1
  • 1
AEMLoviji
  • 3,217
  • 9
  • 37
  • 61
0

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?)

ern0
  • 3,074
  • 25
  • 40