How can i show and hide table rows based on value selected in multiselect?
For example i have below multiselecct box.
<select multiple="multiple" >
<option value="1">foo</option>
<option value="2">bar</option>
<option value="3">baz</option>
<option value="4">toy</option>
</select>
if the user select foo and baz from multiselect then then i am getting selected values as “1,3” in jquery.Now in my html i would only want to show table rows whose id is either 1 or 3.means all the rows will not be visible having id apart from 1 and 3.
Thanks in advance.any help would be much appreciated
If you were to get the
val()of a multi-select, you’d get a comma-separated list of all the selected values. So you need to get this list, split it into an array, and then loop through the array and take action on each value.Something like this:
HTML:
http://jsfiddle.net/MqPzb/
Read about the magic: