Link to home
Start Free TrialLog in
Avatar of MaximusMeridus
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%>">
ASKER CERTIFIED SOLUTION
Avatar of masirof
masirof

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MaximusMeridus
MaximusMeridus

ASKER

How to I have a save or dismiss button on the message box?

Max
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?act=3&pid=<%=pid%>&conf=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/manageproduct.asp?msg=Product%20deleted">
                  <%
            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