The following code is used to check if changes to a form have been made and pops an alert if the person tries to switch pages before submitting the form.
The way it works is on text change of the text fields I set a hidden field to 1 indicating a change has been made to the form.
When they click a link to a different page it runs the following script to check if the hidden field is 1 or 0 if it's 0 it simply send them to the page they requested... if it is 1 then changes have been made to the form and displays the confirm alert... and asks if they want to save the changes. if they click OK it saves the changes and sends them to the changes success page if they click cancel it simple sends them on to the requested page.
This works fine in everything but moz based browsers (netscape, moz, etc).
in moz based browsers it seems to do nothing at all.
Could anyone explain why and maybe offer a solution. I am really frustrated and could use a hand.
The way it works is on text change of the text fields I set a hidden field to 1 indicating a change has been made to the form.
When they click a link to a different page it runs the following script to check if the hidden field is 1 or 0 if it's 0 it simply send them to the page they requested... if it is 1 then changes have been made to the form and displays the confirm alert... and asks if they want to save the changes. if they click OK it saves the changes and sends them to the changes success page if they click cancel it simple sends them on to the requested page.
This works fine in everything but moz based browsers (netscape, moz, etc).
in moz based browsers it seems to do nothing at all.
Could anyone explain why and maybe offer a solution. I am really frustrated and could use a hand.
Code:
function doAlert(theLink) { //v1.0
if (form.changed.value=="0"){
top.location = (theLink);
}
else if (form.changed.value=="1"){
form.changed.value="0";
question=confirm("You have made changes to this page but have not saved the changes by submitting the form.\n\nIF YOU WANT TO SAVE YOUR CHANGES\n > CLICK OK.\n\nIF YOU DON'T WANT TO SAVE YOUR CHANGES\n > CLICK CANCEL");
if (question =="0"){
top.location = (theLink);
}
else{
document.form.submit();
top.location = ('update.php');
}
}
}