>Thanks to IE's inability to dynamically hide/show options within a > select list, I need to do it differenly,
Is this documented somewhere? I think I am having the same problem. >I just had to figure out a similar problem, and >dynamically remove a select option. Thankfully, there >is an easy plugin available: But what if you don't want to remove an option, just hide it? The problem I have is that I want to be able hide/show an option element based on another form field value. If I use remove() then I have to keep track of the values I am removing so that I can put them back in. On Jun 1, 1:25 pm, Kim Johnson <[EMAIL PROTECTED]> wrote: > Hi Luc, > > I just had to figure out a similar problem, and > dynamically remove a select option. Thankfully, there > is an easy plugin available: > > http://www.texotela.co.uk/code/jquery/select/ > > From the page: > > Remove an option by index: > $("#myselect2").removeOption(0); or value: > $("#myselect").removeOption("Value"); or with a > regular expression: > $("#myselect").removeOption(/^val/i);. To remove all > options, you can do $("#myselect").removeOption(/./); > > In my case, I simply want it to remove the default > blank value if they've selected a value, so here's my > code: > > if (obj.attr("id") == "" && obj.containsOption("")) > { > obj.removeOption(0); > > } > > --kim > > --- Luc Pestille <[EMAIL PROTECTED]> wrote: > > > > > Hi all, > > Thanks to IE's inability to dynamically hide/show > > options within a > > select list, I need to do it differenly, but I can't > > get it to work =/. > > This is what works as I'd expect in FF; > > > //this is only for agency jobs - show titles > > dependent on discipline > > selected > > discipline = $("#admin-jobs .discipline_agency_row > > select > > [EMAIL PROTECTED]").val(); > > $("#admin-jobs .jobtitle").hide(); > > titles_needed = "#admin-jobs .discipline" + > > discipline; > > $(titles_needed).show(); > > > $("#admin-jobs .discipline_agency_row > > select").change(function(){ > > $("#admin-jobs .jobtitle").hide(); > > titles_needed = "#admin-jobs .discipline" + > > $(this).val(); > > $(titles_needed).show(); > > }); > > > This is what I've come up with, and logically I > > think it should work, > > but it doesn't. IE strips all the options out (but > > shows the empty > > dropdown) and won't add any back in, and FF doesn't > > strip any out at > > all. > > > //show titles dependent on discipline selected > > $discipline = $("#admin-jobs > > .discipline_agency_row select > > [EMAIL PROTECTED]").val(); > > $titles_needed = "#admin-jobs .discipline" + > > $discipline; > > alloptions = $("#admin-jobs .jobtitle").clone(); > > if ($discipline){ > > reqoptions = alloptions.find( > > "option:not('"+$titles_needed+"')" > > ).remove(); > > $("#admin-jobs .title_row select").empty(); > > $("#admin-jobs .title_row > > select").append(reqoptions); > > } > > > $("#admin-jobs .discipline_agency_row > > select").change(function(){ > > $titles_needed = "#admin-jobs .discipline" + > > $(this).val(); > > alloptions = $("#admin-jobs .jobtitle").clone(); > > if ( $(this).val() ){ > > reqoptions = alloptions.find( > > "option:not('"+$titles_needed+"')" > > ).remove(); > > $("#admin-jobs .title_row select").empty(); > > $("#admin-jobs .title_row > > select").append(reqoptions); > > } > > }); > > > Anyone got a method that does work, or does a plugin > > exist to counter > > IE's bug? > > Luc Pestille > > Web Designer > > > in2, Thames House, Mere Park, Dedmere Road, Marlow, > > Bucks, SL7 1PB > > tel: +44 (1628) 899700 | fax: +44 (1628) 899701 | > > email: [EMAIL PROTECTED] | web:www.in2.co.uk > > This message (and any associated files) is intended > > only for the use of jquery-en@googlegroups.com and > > may contain information that is confidential, > > subject to copyright or constitutes a trade secret. > > If you are not jquery-en@googlegroups.com you are > > hereby notified that any dissemination, copying or > > distribution of this message, or files associated > > with this message, is strictly prohibited. If you > > have received this message in error, please notify > > us immediately by replying to the message and > > deleting it from your computer. Messages sent to and > > from us may be monitored. Any views or opinions > > presented are solely those of the author > > jquery-en@googlegroups.com and do not necessarily > > represent those of the company. > > ____________________________________________________________________________________ > Building a website is a piece of cake. Yahoo! Small Business gives you all > the tools to get online.http://smallbusiness.yahoo.com/webhosting