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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:36:46+00:00 2026-05-13T22:36:46+00:00

The javascript code I now have can toggle a single row of data. Whether

  • 0

The javascript code I now have can toggle a single row of data. Whether JQuery or javascript, how do I toggle multiple rows?

In this example, when location 1 (value = “1”) is selected, I would like to have tr tags “11”, “12”, “13” displayed (Location “1” Building “1” => “11”)and Location 2 displays tr “21”, “22”.

<script type="text/javascript" language="javascript">
 function propertySelected() {
     var Select = document.getElementById('Select');
     var Table = document.getElementsByName('List')[0];
     var strSelect = Select.options[Select.selectedIndex].value;
     var rows = Table.getElementsByTagName("tr");
     var rowSelect = document.getElementById(strSelect);
     for (var i = 0; i < rows.length; i++) {
         rows[i].style.display = 'none';   
         }
         rowSelect.style.display = '';
 }    
</script>

…

<select id="Select" onchange="Selected()">                
   <option value="1">Location 1</option>
   <option value="2">Location 2</option>
   <option value="3">Location 3</option>
</select>

…

<table>
    <tr id="11"><td>Location 1 Build 1</td></tr>
    <tr id="12"><td>Location 1 Build 2</td></tr>
    <tr id="13"><><td>Location 1 Build 3</td></tr>
    <tr id="21" style="display:'none';"><><td>Location 2 Build 1</td></tr>    
    <tr id="22" style="display:'none';"><><td>Location 2 Build 2</td></tr>
    <tr id="31" style="display:'none';"><><td>Location 3 Build 1</td></tr>
</table>
  • 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-13T22:36:46+00:00Added an answer on May 13, 2026 at 10:36 pm

    Instead of hiding all rows and then showing one row, put some logic in the loop so that you hide or show each row depending on the id:

    <script type="text/javascript">
    
    function propertySelected() {
      var Select = document.getElementById('Select');
      var Table = document.getElementsByName('List')[0];
      var strSelect = Select.options[Select.selectedIndex].value;
      var rows = Table.rows;
      var rowSelect = document.getElementById(strSelect);
      for (var i = 0; i < rows.length; i++) {
         var row = rows[i];
         row.style.display = (row.id.substr(0,1) == strSelect) ? '' : 'none';   
      }
    }    
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript code and want to extend this code now. how can
I have this javascript code that creates a slider: http://jsfiddle.net/samccone/ZMkkd/ Now, i want to
I have this jquery code: <script type=text/javascript> jQuery(document).ready(function($){ // hides the slickbox as soon
I've built this piece of code...(javascript) Now we have a red sphere on the
now i made JavaScript code (jquery code) and when i click ok it return
I have this javascript code. var a = FCKeditorAPI.GetInstance(FCKeditor1).GetXHTML(). a += '123'; //insert a
I have a form which can have multiple values in it. For example: Please
I made this PHP chatbox which supports some JavaScript code. I have these 'images'
I have a piece of javascript code. Right now it forces users to manually
I have a JavaScript code coupon.js defined as follows - jQuery(document).ready(function(){ jQuery('.appnitro').submit( function() {

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.