Example Scenario:
Lets say you have a form that has a BACK link. You want to make sure that if the user has made any changes on that form and they click the BACK that they REALLY want to leave the page.
So on your input boxes you can place an onChange event that sets a global variable to true (yes this form has been changed!)… i.e. onchange=”g_bformChanged=true;”
Then on your back button just fire off your function that checks to see if the form has changed… using your CONFIRM box to get a confirmation from your user.
<script type="text/javascript"> //Global var g_bformChanged = false; function checkForSaveNeed() { if (g_bformChanged) { var confirmLeave = confirm("No changes will be saved. Are you sure you want to leave?"); if (confirmLeave == true) { window.location = "ManageSchools.aspx" } } else window.location = "ManageSchools.aspx"; } </script>
