By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

GOOD SCRIPT BUT JUST ONE PROBLEM : Stop an "Unonload" when then confirmation is false

P: 1
Problem : Stop an "Unonlaod" when then confirmation is false.

Is a really good script but i have just one problem. The problem that i have is when i click on a link. The scipt ask "Do you want to save DATA". When you click "Yes" and the name form is empty. The script tell you a message, but i go to another page. ALL I WANT IS TO BLOCK IT, AND STAY IN THE SAME PAGE WITHOUT RELOADING. LIKE WHEN YOU CLICK SUBMIT.

Can some one help me ?
Is a good script but i have only one problem ?
donald.loignon@cgocable.ca


Here is the script

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body onunload="CloseWindowSauvegarde()">

<p>
<SCRIPT LANGUAGE="JavaScript">

function CloseWindowSauvegarde ()
{
var answer = confirm ("DO YOU WANT TO SAVE DATA")
if (answer)
{
return FrontPage_Form1_Validator(formulaire);
}
else
{
alert ("LOST YOUR DATA");
}
}

// *********** VALIDATION
function FrontPage_Form1_Validator(theForm)
{
if ((theForm.Nom.value.length < 1) || (theForm.Nom.length > 225))
{
alert("NAME must contain NAME OF the COMPANY must contain between 1 and 225 characters. ");
theForm.Nom.focus();
return (false);
}
return (true);
document.formulaire.submit ();
}


</script>
</p>
<p><a href="http://www.google.ca">Change lick with save</a></p>
<form name="formulaire" method="post" action="s-compagnie.asp" onsubmit="return FrontPage_Form1_Validator(this)">
Name :
<input name="Nom" type="text" id="Nom">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
Sep 22 '06 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
Problem : Stop an "Unonlaod" when then confirmation is false.

Is a really good script but i have just one problem. The problem that i have is when i click on a link. The scipt ask "Do you want to save DATA". When you click "Yes" and the name form is empty. The script tell you a message, but i go to another page. ALL I WANT IS TO BLOCK IT, AND STAY IN THE SAME PAGE WITHOUT RELOADING. LIKE WHEN YOU CLICK SUBMIT.

Can some one help me ?
Is a good script but i have only one problem ?
donald.loignon@cgocable.ca


Here is the script

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body onunload="CloseWindowSauvegarde()">

<p>
<SCRIPT LANGUAGE="JavaScript">

function CloseWindowSauvegarde ()
{
var answer = confirm ("DO YOU WANT TO SAVE DATA")
if (answer)
{
return FrontPage_Form1_Validator(formulaire);
}
else
{
alert ("LOST YOUR DATA");
}
}

// *********** VALIDATION
function FrontPage_Form1_Validator(theForm)
{
if ((theForm.Nom.value.length < 1) || (theForm.Nom.length > 225))
{
alert("NAME must contain NAME OF the COMPANY must contain between 1 and 225 characters. ");
theForm.Nom.focus();
return (false);
}
return (true);
document.formulaire.submit ();
}


</script>
</p>
<p><a href="http://www.google.ca">Change lick with save</a></p>
<form name="formulaire" method="post" action="s-compagnie.asp" onsubmit="return FrontPage_Form1_Validator(this)">
Name :
<input name="Nom" type="text" id="Nom">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
I think you should remove this

document.formulaire.submit ();
Sep 22 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.