Skip to content Skip to sidebar Skip to footer

Hide() Not Working In Ie

My code works perfect in firefox and gives error in IE. any ideas? I have a dropdown with various options, I am trying to show/hide options in another dropdown based on the select

Solution 1:

Make sure you close the start tag. Try to use this:

<select>
    <optionclass="Name1" value="SomeName1" />
    <optionclass="Name2" value="SomeName2" />
</select>
<select id="SelectName" onchange="javascript:selectNames();" >
    <option value="Name1" />
    <option value="Name2" />
</select>

Seems to work for me in IE8.

Solution 2:

It won't work in IE & Chrome

check out in IE or Chrome

The best alternative that you can do is to remove the option rather than hiding it.(you should keep a copy of the original options before removing it.)

var copy = $("."+Name).clone();
functionselectNames() {
   $("#thefirstselect option").remove();
   copy.appendTo("#thefirstselect");
   varName = $("#SelectName").val();

   $("."+Name).each(function() {
      $(this).remove();            
});
}

Solution 3:

Your markup is not correct. You are each option open tag isn't properly closed.

Also, the specs do not specify CSS changes to individual option tags, though it does work on Firefox.

In simpler words, you cannot hide individual inputs - in which case, you'll have to remove them.

Solution 4:

If this is a direct copy and paste then you need to close the select options to look like this:

<optionvalue="Name1">Name1</option><optionvalue="Name2">Name2</option>

Solution 5:

I would suggest having two selects that you show and hide. Show and hide of options sounds risky.

Also, make sure you set the hidden select to attr('disabled','disabled')/disabled="disabled" and then when you unhide it undo that with removeAttr('disabled'). This is to prevent the hidden select from posting data to the server when you have multiple selects with the same name="...".

If you must use a single select, you may want to appendTo/remove the options, but that is up to you. If show/hide works in all browsers, go for it.

Post a Comment for "Hide() Not Working In Ie"