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!

reference value from a table row

Status
Not open for further replies.

cylly

Programmer
Oct 17, 2002
23
CA
I am trying to set a variable from a value in a table that is loaded dynamically.
Here is my table setup.
<TABLE border=1>
<TR>
<b>
<TH>Table Name</TH>
<TH>Description</TH>
</b>
</TR>
<p font-size=10>
<pr:iterator results=&quot;tableList&quot; >
<TR id=&quot;<pr:field name='table_nm'/>&quot; onClick=&quot;highlightTR('#c9cc99','cc3333',this.id);&quot;>
<TD><pr:field name=&quot;table_nm&quot;/></TD>
<TD><pr:field name=&quot;table_descv_txt&quot;/></TD>
<TD>
<form method=get name=myform action=&quot;TableUpdate.jsp&quot;>
<input type=hidden name=tName value=&quot;<pr:field name=&quot;table_nm&quot;/>&quot;>
<input type=hidden name=tDesc value=&quot;<pr:field name=&quot;table_descv_txt&quot;/>&quot;>
<input type=hidden name=tNum value=&quot;<pr:field name=&quot;generic_table_num&quot;/>&quot;>
</form>
</TD>
</TR>
</pr:iterator>
</TABLE>

I am trying to get the values of tName, tDesc and tNum depending on the table row id. How do I do this in script?

Thanks.
 
Since you're putting the fields in their own form as you're looping through the results, you could name the rows row0, row1, row2, etc. Then in your function extract the row number from the row id and use it to determine which form to pull the data from:

function highlightTR(color1,color2,id){
theForm=forms[id.substring(3)-0]
alert(theForm.tName.value)
alert(theForm.tDesc.value)
alert(theForm.tNum.value)
} Adam
 
That sounds like a great idea but how do I name the table row with a number when I don't know how many rows there will be? I will need to increase the number for each time it iterates to create the table rows.
 
Does anybody have an answer for me?
 
I'm not familiar enough with ASP.NET to give you a good answer. In regular ASP, I'd declare a variable...
<%Dim count = 0%>

...use &quot;count&quot; in the row name as I'm looping...
<tr id=&quot;row<%=count%>&quot;>

...and add 1 to &quot;count&quot; before the end of each loop...
<%count=count+1%>

I'm not sure how you do it in ASP.NET, maybe you can add the counter variable to the row id with an asp.net tag, then call a function from within the loop that will increment the variable. Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top