MaximusMeridus
asked on
Submit question on Exit page
Hi there,
I have a page with a form to database
When exiting the page, I want it to ask me whether I would like to save or dismiss changes
I have so far the following..how do I apply this so that it submits the form if ok is clicked?
Thanks
Max
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit()
{
var agree=confirm("Are you sure you want to exit? \n\n Please save changes or cancel them!");
if (agree)
return true ;
else
return false ;
}
// -->
</script>
</head>
<BODY onUnload="return confirmSubmit()">
<form name="company" method="POST" action="<%=MM_editAction%> ">
I have a page with a form to database
When exiting the page, I want it to ask me whether I would like to save or dismiss changes
I have so far the following..how do I apply this so that it submits the form if ok is clicked?
Thanks
Max
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit()
{
var agree=confirm("Are you sure you want to exit? \n\n Please save changes or cancel them!");
if (agree)
return true ;
else
return false ;
}
// -->
</script>
</head>
<BODY onUnload="return confirmSubmit()">
<form name="company" method="POST" action="<%=MM_editAction%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I dont use JavaScript for this as you cannot easily (as far as I know) modify the look and options of the dialog box. I prefer to use a separate section of my ASP page to act as a confirmation.
Dim conf
conf = Trim(Request.QueryString(" conf"))
If conf <> "yes" Then
%>
<h1 style="text-align:center;" >Confirm deletion</h1>
<div id="dialog">
<p>Are you sure you wish to delete this PRODUCT from the database? This action cannot be undone !</p>
<div class="button" style="float:left;"><a href="manageproduct.asp?ac t=3&pid=<% =pid%>&con f=yes">Yes - Delete</a></div>
<div class="button" style="float:right;"><a href="/manageproduct.asp"> No - Go back</a></div>
</div>
<%
Response.End
ElseIf conf = "yes" Then
Con.Execute("DELETE FROM tbl_Product WHERE productID=" & pid)
%>
<meta http-equiv="refresh" content="0;URL=/admin/mana geproduct. asp?msg=Pr oduct%20de leted">
<%
End If
Something like that. this can be customised to show a record or the contents of the form and then it is simpkly amatter of clicking Confirm or Discard or whatever else you want to use.
If you need extra help with implementing this, just ask
HTH
C
Dim conf
conf = Trim(Request.QueryString("
If conf <> "yes" Then
%>
<h1 style="text-align:center;"
<div id="dialog">
<p>Are you sure you wish to delete this PRODUCT from the database? This action cannot be undone !</p>
<div class="button" style="float:left;"><a href="manageproduct.asp?ac
<div class="button" style="float:right;"><a href="/manageproduct.asp">
</div>
<%
Response.End
ElseIf conf = "yes" Then
Con.Execute("DELETE FROM tbl_Product WHERE productID=" & pid)
%>
<meta http-equiv="refresh" content="0;URL=/admin/mana
<%
End If
Something like that. this can be customised to show a record or the contents of the form and then it is simpkly amatter of clicking Confirm or Discard or whatever else you want to use.
If you need extra help with implementing this, just ask
HTH
C
ASKER
Max