PDA

Click to See Complete Forum and Search --> : submit question


ober0330
Mar 3rd, 2004, 10:55 AM
How do I ask the user if they want to submit a form or not? And if they say no, I want to stop anything from happening.

The Hobo
Mar 3rd, 2004, 11:27 AM
I don't think JavaScript has the ability for a Yes/No type of prompt box. You could use a prompt box and have them type in Yes or No, but that's not very cool.

Maybe someone else will have a better answer, but here's the prompt() thing:


<html>
<head>
<title></title>
<script type="text/javascript">
function confirm() {
var res = prompt('Submit This Form? (yes or no)', 'Yes');

if (res == 'yes' || res == 'Yes') {
return true;
} else {
return false;
}
}
</script>
</head>
<body>
<form action="this.php" method="post" onsubmit="return confirm();">
<input type="submit" name="submit" value=" Submit " />
</form>
</body>
</html>