Link to home
Start Free TrialLog in
Avatar of inexplicable
inexplicable

asked on

Show Hide Multiple rows using same ID

Ive a table which displays some history of an user and that is displayed in different rows. So the structure is something like this :

- Member Name
-- History1
-- History 2

Basically the number of "History" rows is determined by the database since its dynamically created. There would be named like "name1", "name2", "name3"...and so on. So i need a way to show/hide these rows based on the name i pass. For instance if i pass "mark" to the javascript function, it should show/hide all rows that use "mark" in their id. See code example below for reference.

<table border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td bgcolor="#D6C899" class="borderbrowndotted"><strong><a href="#" onCLick="showhide('mark')">Name</a></strong></td>
    <td bgcolor="#F4E9C4" class="borderbrown">&nbsp;</td>
    <td bgcolor="#F4E9C4" class="borderbrown">&nbsp;</td>
    <td bgcolor="#F4E9C4" class="borderbrown">&nbsp;</td>
  </tr>
  <tr id="mark1" style="display:none">
    <td bgcolor="#CCCCCC" class="borderbrowndotted">15/1/2005</td>
    <td bgcolor="#FAF2D7" class="borderbrown">a</td>
    <td bgcolor="#FAF2D7" class="borderbrown">a</td>
    <td bgcolor="#FAF2D7" class="borderbrown">a</td>
  </tr>
  <tr id="mark2" style="display:none">
    <td bgcolor="#CCCCCC" class="borderbrowndotted">15/1/2005</td>
    <td bgcolor="#FAF2D7" class="borderbrown">b</td>
    <td bgcolor="#FAF2D7" class="borderbrown">b</td>
    <td bgcolor="#FAF2D7" class="borderbrown">b</td>
  </tr>
</table>
ASKER CERTIFIED SOLUTION
Avatar of GwynforWeb
GwynforWeb
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of inexplicable
inexplicable

ASKER

Doesnt work. It gives error for some reason "Object required"
I have just retested the above code in IE and FireFox and it works for me
..make sure the table has an id
Excellent works fine now. My bad!