Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass data from table to popup ?

Status
Not open for further replies.

aatishbh

Programmer
Jun 29, 2004
3
US
I have a table which is created dynamically using the <netui-data:repeater > tags.
I have made the 1st column to be a column of hyperlinks. Following is the code that I am using.


<netui-data:repeaterItem>
<tr class="contenteven" onmouseover="this.className='mouseovercolor'" onmouseout="this.className='mouseoutcolor'">
<td><span><a href="javascript: i=i+1;openwindow(i);" ><netui:label id=" %i++;%>" styleClass="labell" value="{container.item.strSR_NBR}" >
</netui:label></a></td>

<td align="center"><netui:label value="{container.item.strDATE}">
</netui:label></td>

<td align="center"><netui:label value="{container.item.strNAME}">
</netui:label></td>

</tr>
</netui-data:repeaterItem>


It prints:

SR# DATE NAME
15-34534-345 2004/09/27 Smith Will
15-34534-333 2004/09/27 JOHN Brawny
15-34534-332 2004/09/27 JOEY TRIBIANNI

Please keep in mind that the table length will vary everytime.

On clicking the 1st row 1st column, it should open a page which will display more information about row1.

I just don't know how can I keep track of the row which the user will click. I have tried various options but haven't got it to work yet. Please let me know if you have ay more suggestions.

Thanks in advance!
 

If you pass "this" into your openwindow function, then climb backwards up the DOM until you find a TR tag, then you should be sorted... Something like this:

Code:
<tr...>
   <td><span><a href="javascript:openwindow(this);">...</a></span></td>
</tr>

With your openwindow looking like this:

Code:
function openwindow(element) {
   while (element.tagName.toLowerCase() != 'tr') element = element.parentNode;

   // at this stage, element will point to the row, so you can harvest any information you need
}

Hope this helps,
Dan
 
I tried doing it but it says that tagName is either not an Object or is null.

Also,could you tell me how do I extract the information from the element object. I am using it for the first time.

Thanks!
 

You should only ever get the "null or not an object" error if you have failed to put a "TR" tag in place, or are calling taht routine outside of a table.

You don't "extract" information from element - you read/write its properties and execute its methods just as you would the TR object itself.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top