mozgheib
There are many ways to skin a cat, your way will work. I believe the more conventional way to achieve this is to pass a records unique ID instead of the row number.
The way casselj has illustrated will also work. IMO a bad pratice to have so many forms on a page. If you had 50 records in your record set, you are going to have 50 froms on the page. This is not ideal.
Your query is select * from mytable. Does this table have a unique auto incrementing primary key field? Even if you dont think you need it, put one in there call it ID (or what ever) then forget about it. Then when you want to edit, update and delete records things are much much easier.
I noticed you had your <tr> tag outside the loop. I am guessing you have not run the code? this is why I will be brief. Here is how I would handle it:
1..Add a hidden field outside your loop:
<input type="hidden" name="idToDelete" value="">
2..Inside your loop change your button to:
<input type="button" value="delete" onClick="SomeFunctionName(rs(0));">
Note: rs(0) is the record which represents the unique ID of the record. This may be called rs("fieldName") also.
3..Now in the head of your document inside
JS tags (where are your <head></head><title></title> tags in your example? every page that has a user interface should have them):
<script language="javascript">
function SomeFunctionName(idbeingPassed)
{
//you should place an alert here confirming the delete
myForm.idToDelete.value = idbeingPassed;
myForm.submit();
}
</script>
now place this delete code above the following line:
set rs.open="select * from mytable",conn
if request.form("idToDelete") <> "" then
sql = "DELETE FROM mytable WHERE id=" & request.form("idToDelete") & ";"
end if
NOTE: ID should be replaced with the name of your unique field. If you dont place the delete above your initial select code the deleted record will still show.
Wind is your friend
Matt