Link to home
Start Free TrialLog in
Avatar of TrystHughes
TrystHughes

asked on

How can I show/hide rows in a HTML table, but 1st row always show

Hi all,

I am generated some HTML / Javascript through the use of some XSLT, and what I aim to do is generate a table with many rows where we always have the 1st row showing (which has a +/- image there for users to click so that they can expand/collapse the rest of the rows in that table). I am having trouble with the Javascript on assigning the relevant class to the rows so that they get hidden or shown.

So far my XSL is generating the HTML table that is shown.

I know I am violating HTML here by having many tags with the same ID, but I am just looking for ways to get this to work.

Is anyone able to help me out a bit here and also suggest what I place in my 'ShowHide()' javascript method?

Thanks in advance
<table class="InfoBlock" cellspacing="0" cellpadding="0">
      <col class="report_column_headings">
      <col class="report_column_headings">
      <tbody>
        <th>Date</th>
        <th>Capital</th>
        <tr class="search_results_row_colour">
          <td class="collection_list"><a onClick="ShowHide('ID0EKFAC')"><img src="images/panel_Plus.gif" alt="expand/collapse section" class="expandable" onclick="changepic()" border="0"></a>07-03-2005</td>
          <td class="collection_list">3,000,000</td>
        </tr>
        <tr class="collapsed" id="ID0EOFAC">
          <td class="collection_list">27-07-2002</td>
          <td class="collection_list">15,000,000</td>
        </tr>
        <tr class="collapsed" id="ID0ESFAC">
          <td class="collection_list">23-10-2000</td>
          <td class="collection_list">100,000</td>
        </tr>
      </tbody>
    </table>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of bugada
bugada
Flag of Italy 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
SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America 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 metta0_3
metta0_3

Well CSS for hiding would be Create an inline style to have initially hidden control using below CSS

Style = "display:none"

There is also a javascript show method.

function ShowItem() {
    document.getElementById('controlID').show();
}

function hideItem() {
document.getElementById('controlID').style.visibility = 'hidden';
}
Put the ShowHide() function in the <head> section of the document between beginning and ending script tags, like this:
<script type='text/javascript'>
  function ShowHide() {
    ...
  }
</script>

Open in new window

SOLUTION
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
oops, HonorGod beat me to the punch.
Avatar of TrystHughes

ASKER

Hi all, and thanks for teh replies :)

It looks like i am going down the <thead><tbody> route, but I am having trouble with my XSL output side of this at the moment, but once I crack this I will come back onto Javascript side of it here.

...brb...
Thanks for the assist, and the points.

I'm sorry that you felt the answer(s) only warranted a B

Good luck & have a great day