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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select a row then perform a function using a submit button

Status
Not open for further replies.

cylly

Programmer
Oct 17, 2002
23
CA
I am trying to found out how I can select a row from a list or a table. After making a selection I would like to then use a submit button (example - edit) using the row I selected. It was suggested that I use radio buttons along the side of my list but I would rather not use them if I can avoid it.
 
First you have to explain what do you mean by "select a row" and what action should be performed with "using the row I selected" when you submit a form.

If not, all you'get in responce will be like this:
. . .
<tr onclick=&quot;doSomething();&quot;>
<td> . .
 
In a table I have a list of name and description.
Like this...

NAME DESCRIPTION
country_cd list of all country codes
status_change_xr status change cross reference

I would like to be able to click on country_cd and highlight it so that it is selected. I would then like to click on an 'edit' button to take me to a new page to edit the row I just clicked on.
 
OK, here's one idea:

<script>
function mark(element, item) {

// put some code here to mark or highlight the selection if you want,
// like this:
// document.getElementById(element).style.color = &quot;red&quot;;
// search JS forum for posts about it.

document.form1.action = &quot;somescript.cgi?item=&quot; + item;
}
</script>

. . .
<tr id=&quot;first&quot; onclick=&quot;mark('first', 'country_cd');&quot;>
<td>country_cd</td>
<td>list of all country codes</td>
</tr>
<tr id=&quot;second&quot; onclick=&quot;mark('second', 'status_change_xr');&quot;>
<td>status_change_xr</td>
<td>status change cross reference</td>
</tr>
. . .
<form name=form1>
. . .
<input type=&quot;submit&quot;>
</form>

I think that it is clear enough what goes here. You pass the NAME as a parameter to some server script that will execute accordingly.
 
Thanks for the idea.
My table is a little more complicated though.
Here is my code. What am I missing? I am getting an IE Script Error.

<script>
int i
i = 0;
function getcount()
{

i=i+1;
myform.rowcnt = i;
}

function mark(element,item)
{
document.getElementById(element).style.color = &quot;blue&quot;;

}
</script>


<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=i onclick=&quot;mark(i,'country_cd');&quot;>
<TD><pr:field name=&quot;table_nm&quot;/></TD>
<TD><pr:field name=&quot;table_descv_txt&quot;/></TD>
<TD>
<form name=myform method=get 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;>
<input type=hidden name=rowcnt value=getcount()>
</form>
</TD>
</TR>
</pr:iterator>
</TABLE>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top