jquery reset conditional filter
Posted
by VictorS
on Stack Overflow
See other posts from Stack Overflow
or by VictorS
Published on 2010-04-21T22:18:52Z
Indexed on
2010/04/21
23:53 UTC
Read the original article
Hit count: 232
I have 2 dropdown lists on my webform and using jquery trying to filter/reset filter 2nd dropdown elements based on 1st dropdown selection.
$(document).ready(function()
{
$('#dropdown1').change(function(e)
{
switch ($(this).val())
{
case "4":
//this removal works
$('#dropdown2').filter(function()
{
return ($(this).val() == 16);
}).remove();
break;
.................
default:
//how would I restore filter here?
}
}
});
Removing part works, so it filters item with no problem, but I have difficulty restoring the filter on dropdown 2 if something else is chosen in dropdown 1. I was trying to use .hide()
and .show()
instead of .remove()
but it doesn't seem to work on IE6 at least.
© Stack Overflow or respective owner