Link to home
Start Free TrialLog in
Avatar of CycnoAB
CycnoAB

asked on

How do I iterate nameless elements

Hello.
I'm programming an application that displays a list of selected database tulips with some restriction in information due to simplicity in the list. However I got a request to enable an option to "expand" every row, displaying the "short description" of the tulip. Easy enough. Now, when a user select a table row it displays the complete information in another frame and sets the row to selected. This works fine with one row, but with the expanding row I've encountered problems. With my current scipt I only select the first row.
Here's an example:

<tr onmouseover="className='highlight_row';" class="e_r" onmouseout="m_ou(this,'e_r');"onclick="cli(this,'e_r',99,'all');">
      <td width="15" style="padding-left: 2px;">&nbsp;</td>
      <td nowrap>Company name</td>
      <td nowrap>Contract description</td>
      <td align="right"><img title="Copy to clipboard" onclick="cli_copy(99);" height="12" src="../images/copy.gif" width="12">&nbsp;</td>
</tr>
<tr class='e_r'>
      <td>&nbsp;</td>
      <td colspan='3'>Expanded description using 3 columns.</td>
</tr>

Without the expanded row the last TR is not executed.
I realize I might be able to work around this by putting it all into a table in each row in the main table, but my curiousity drives me to see if there is a way to solve this. The javascript function works as follow atm:
function cli(t,r,ci,op)
{
      -[data removed]-
      try{
            document.getElementById("h").className=old_rowtype;
            document.getElementById("h").id="";
      }catch(error){};
      t.id="h";
    old_rowtype=r;
    t.className="s_row";
}

So, how do I set both rows to selected (and deselect them when a new one is set)?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands 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 CycnoAB
CycnoAB

ASKER

That was a very interesting piece of code I must admit.
What is the tbody entity you use? Does it work with table, the one I'm accustomed to? Because i tried and nothing happens (used IE and FF).

My problem pretty much comes down to changing class of the following TR class, so I guess I could change the name of the second one. I found a function called nextSibling which works out fine in IE, but not in FF. Is there a similat function to parentNode? Like nextNode or something like that?
<tbody>,<thead>,<tfoot> are table tags using which you can group tr's.

You can have a single thead, multiple tbodys and single tfoot.

-r-
Avatar of CycnoAB

ASKER

What's the pro:s of using them?
Are there any requirements to use them btw, since it's not working for me?