[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

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%>">
0
MaximusMeridus
Asked:
MaximusMeridus
1 Solution
 
masirofCommented:
formname.submit();
0
 
MaximusMeridusAuthor Commented:
How to I have a save or dismiss button on the message box?

Max
0
 
snavebelacCommented:
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
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now