How to I have a save or dismiss button on the message box?
Max
Main Topics
Browse All TopicsHi 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%>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
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("
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
Business Accounts
Answer for Membership
by: masirofPosted on 2005-04-15 at 04:41:51ID: 13789747
formname.submit();