Trick was to run a redirect after the delete code,
redirecting back to the
same page so that it was forced to properly reload itself,
thereby wiping
out the value indicating that the Delete button had been
pushed.
Apparently coming back and running the "reload" button didn't
reset the
value of the Delete key having been pressed - so the delete
would occur
again and delete any new record that had been created in the
meantime.
"R" <martinistraightup@gmail.com> wrote in message
news:ejb8n6$pgc$1@forums.macromedia.com...
>I have a button on a form on an asp page that runs a
little code to delete
>a
> record. Problem is, when the page is refreshed with a JS
page reload code
> (see below), the code runs and deletes the record again
(after having
> created a new one, which is supposed to happen)!
>
> What am I overlooking here? I know I've done this in
past, but it's been
> a
> while. Would appreciate a quick peek and someone to
point out what I'm
> forgetting!
>
> Here is the code to delete the record:
>
> <% 'CODE TO DELETE MOD 3 TEST RECORDS
>
> If (Request("DELETE") <> "") Then
> Set comDelete = Server.CreateObject("ADODB.Recordset")
> comDelete.ActiveConnection = MM_connRI_STRING
>
> SQL = "DELETE FROM dbo.UserModuleStatus WHERE UserID = "
& svUserID & "
> AND
> ModuleID = 20063"
> 'Response.Write(SQL)
> comDelete.Source = SQL
> comDelete.CursorType = 0
> comDelete.CursorLocation = 2
> comDelete.LockType = 1
> comDelete.Open()
> comDelete_numRows = 0
>
> END IF
>
> %>
>
> And here is the code for the form and my button:
>
> <form action="06modules_temp.asp" method="post"
name="formDelete"
> id="formDelete">
> <div align="center">
> <p>** TO ASSIST IN TESTING MODULE 3 ONLY
**<br>
> <br>
> Click the "Delete" button to delete
your Module 3 test
> record. <br>
> <br>
>
> <input name="DELETE" type="submit" id="DELETE"
value="DELETE">
> </p>
> <p>Then click "Refresh Table"
below. <br>
> <br>
> </p>
> </div>
> </form>
>
> Refresh button:
>
> <input name="Reset" type="reset" class="btnblu"
> onClick="MM_callJS('window.location.reload()')"
value="Refresh Table">
>
>
> Thanks in advance!
>
>
>