0
form button code runs on JS refresh?
LEGEND
,
/t5/dreamweaver-discussions/form-button-code-runs-on-js-refresh/td-p/266224
Nov 13, 2006
Nov 13, 2006
Copy link to clipboard
Copied
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!
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!
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
LATEST
/t5/dreamweaver-discussions/form-button-code-runs-on-js-refresh/m-p/266225#M147085
Nov 14, 2006
Nov 14, 2006
Copy link to clipboard
Copied
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!
>
>
>
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!
>
>
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

