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 8995791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:40:00+00:00 2026-06-15T23:40:00+00:00

How do implement the jquery if I want when selected 1 the table will

  • 0

How do implement the jquery if I want when selected 1 the table will only show tr 1 and when I selected 2 it will show tr 2 and etc?

<select name="select_main_table">
<option value="1" selected="selected">Show line 1</option>
<option value="2" >Show line 2</option>
<option value="3" >Show line 3</option>
</select>

<table id="main_table">
 <tr id="show1"><td>line 1</td><td<line 1/td></tr>
 <tr id="show2"><td>line 2</td><td<line 2/td></tr>
 <tr id="show3"><td>line 2</td><td<line 2/td></tr> 
</table>

Thanks in advance?

  • 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-06-15T23:40:00+00:00Added an answer on June 15, 2026 at 11:40 pm

    Perhaps a little something like this:

    $(document).ready(function() {
       $('select[name="select_main_table"]').change(function() {
          $("#main_table tr").show().slice(this.value).hide();
       }).change();
    });
    

    ​Demo: http://jsfiddle.net/kms8k/

    EDIT: I think my original answer was based on a misunderstanding of your requirement – I thought you meant that selecting “2” meant “show the first two lines”. To show only the specified line do this:

    $(document).ready(function() {
       $('select[name="select_main_table"]').change(function() {
          $("#main_table tr").hide().eq(this.value-1).show();
          // OR
          $("#show" + this.value).show().siblings().hide();
       }).change();
    });
    

    Demo: http://jsfiddle.net/kms8k/1/

    Notice that you can make it work without using the id attribute of the tr elements, should you wish to simplify your html by not including that attribute at all…

    All of the jQuery methods I’ve used are well documented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to implement a dynamic drop down which will select , batch of
I want to implement jQuery Mobile, but only for mobile browsers. Is there a
I have a drop-down list as, <select id='idleReason' onChange=loadXMLDoc(this.value) size=1> <option value=nothing selected=selected>Select a
I want to implement something with jquery, simple javascript and java but I don't
I want to implement the looping through the pictures with HTML, CSS, Jquery/Javascript in
I'm building an ASP.NET MVC site where I want to implement jQuery AJAX calls
I'm playing around with jQuery Isotope and want to implement an element search. When
I want to use Jquery to implement a page that contains js from quotemedia.com.
I want to use Jquery UI Sortable to implement drag-drop and sortable display. In
I want to implement jquery textbox auto suggest in my c# asp.net application for

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.