Click to See Complete Forum and Search --> : confirm window in form


etter
04-30-2003, 05:56 AM
Below you see what i have till now. This script calls a confirm window when you click the submit button. I want that when the user clicks ok, another php script is loaded in the browser window, but i don't know how to do this in javascript. Please help me!

<script language="JavaScript">
<!--
function confirm_entry()
{
input_box=confirm("Click OK or Cancel to Continue");
if (input_box==true)

{
// Output when OK is clicked
alert ("You clicked OK");
}

else
{
// Output when Cancel is clicked
alert ("You clicked cancel");
}

}
-->
</script>

<form onSubmit="confirm_entry()">
<input type="submit" >
</form>

khalidali63
04-30-2003, 06:57 AM
just add this line after
alert ("You clicked cancel");
return false;

and make your form look like this
<form onSubmit="return confirm_entry();">

requestcode
04-30-2003, 07:50 AM
Is the PHP script used to replace the form? If so then you might try this:
function confirm_entry()
{
if(confirm("Click OK or Cancel to Continue"))
{
// Output when OK is clicked
location.href="myscript.php"
}
else
{
// Output when Cancel is clicked
alert("You clicked cancel")
}

}

etter
04-30-2003, 08:19 AM
yes that with href is exactly what i needed!
thanks!