Click to See Complete Forum and Search --> : How to get RowNumber from html table populated by a recordset


mozgheib
06-13-2005, 06:45 AM
Hello,

I have a html table which I am populating its fields by looping
around a recordset. For each row populated I have a delete
button.

The problem is when deleting I need to know which row I am
positioned at when I hit delete mainly since each column
in my row is a list of values including my delete button.

Please advise.

Thanks.

phpnovice
06-13-2005, 10:39 AM
Merely insert the key to the row into the code for the delete button. The following is PHP code, which I happen to have readily available, and is for an Edit button, but the concept is the same:

<a href="<?=$admin?>?start=<?=$row[0]?>"><img border="0"
src="btnEdit.bmp" width="27" height="20" alt="Edit"></a>

mozgheib
06-13-2005, 01:20 PM
My page is an asp page could you pls modify the code to tell me how to
pick the position number:

<% dim ofield1
set rs.open="select * from mytable",conn
ofield1 = request.form("ifield1") 'This is where I need to reflect the position of the row
if delete <> "" then
set rs.execute "delete from mytable where field1=ofield1"
end if
%>


<html
<body>
<form name="myform" action="myfile.asp" method=post>
<table>
<tr>
<%while not rs.eof%>

<input name=ifield1 type = text value="<% =rs("field1") %>">
<input name=ifield2 type = text value="<% =rs("field1") %>">
<input type=button value="delete">
</tr>
<% rs.movenext
wend %>
</table>
</form>
</body>
</html>

phpnovice
06-13-2005, 01:53 PM
Instead of an INPUT TYPE=BUTTON, you'll want to use something similar to what I posted. Just change the <? to <% and the ?> to %> for it to work in ASP.

mozgheib
06-13-2005, 02:17 PM
i tried it see below I am not sure if it will work.See my href or at least
when I click it should submit the page. But in your example you are using
href for something else. Can you please elaborate a bit
<a href="<% =$admin %> ?start= <% =$row[0] %>" onclick="Javascript:document.myform.submit()">delete</a>

phpnovice
06-13-2005, 03:06 PM
No, you don't want to submit the page for a delete. You just want to include the key in the link. In my link, the name of the page is contained in the $admin variable and the value of the key is in the $row[0] variable.

mozgheib
06-13-2005, 03:32 PM
I replaced $admin by http://localhost/pagename.asp
regarding the $row[0] I replaced it by the name of the control which
is textboxname[0] It returns nothing. Please see code below.

<table>

<tr><td><input type=text value="1" name="fcolumn">first</td>
<td><input type=text value="2" name="scolumn">second</td>
<a href="http://localhost/newtest.asp?myrow=fcolumn[0]">first</a></td></tr>

</table>

I really appreciate it if you can resolve this

mozgheib
06-13-2005, 04:53 PM
thanks. I figured it out. thanks again