Submit question on Exit page

Posted on 2005-04-15
Last Modified: 2008-02-01
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 do I apply this so that it submits the form if ok is clicked?



<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 ;
      return false ;
// -->

<BODY onUnload="return confirmSubmit()">
<form name="company" method="POST" action="<%=MM_editAction%>">
Question by:MaximusMeridus
    LVL 6

    Accepted Solution

    LVL 1

    Author Comment

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

    LVL 6

    Expert Comment

    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>
                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



    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    How to solve this equation 3 43
    Issue with Loop 4 34
    Add server behaviors to Dreamweaver CC 2015 2 46
    SP to delete duplicates 15 46
    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now