Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7701359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:57:55+00:00 2026-05-31T22:57:55+00:00

How can i show and hide table rows based on value selected in multiselect?

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:57:56+00:00Added an answer on May 31, 2026 at 10:57 pm

    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:

    $('#test').on('change', function() {
        var numstr = $(this).val() + "";
        var numarr = numstr.split(',');
    
        $('tr[id^=row]').hide();
        $.each(numarr, function(i, val) {
            $('tr#row' + val).show();
        });
    });​
    

    HTML:

    <select id="test" name="test" multiple="multiple" >
    <option value="1">foo</option>
    <option value="2">bar</option>
    <option value="3">baz</option>
    <option value="4">toy</option>
    </select>
    
    ​<table>
    <tr id="row1"><td>1</td></tr>
    <tr id="row2"><td>2</td></tr>
    <tr id="row3"><td>3</td></tr>
    <tr id="row4"><td>4</td></tr>
    </table>​
    

    http://jsfiddle.net/MqPzb/

    Read about the magic:

    • http://api.jquery.com/change/
    • http://api.jquery.com/on/
    • http://api.jquery.com/jQuery.each/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works like a charm to show/hide table rows based on selected filters.
My question is, why I can not use hide() & show() to hide/show table
I have a menu with submenus that can be toggled (hide/show type deal). Is
I have a mutliple drop down menus that I am using to hide/show rows
I want to be able to show/hide the rows in a table using jquery.
I have this JQuery script: $('#searchinput').keypress(function() { $('#realadstable tr').show().not(':contains(' + this.value + ')').hide(); });
how can i use jQuery to show/hide the same div area... essentially swapping out
I've always been curious to see if I can show, hide or change a
Is there a control like System.Windows.Controls.GroupBox that can hide its contents and show only
if so can show simple example, ex in jquery ajax.post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.