"Aaron C" <ag********@comcast.net> wrote in message
news:Yo********************@comcast.com...
I'm validating a form that has two buttons ("Next" and "Back"). The call
to the script is currently in the form's onSubmit() handler. Upon
pressing either button, the script runs. This is understandable, since
either button press is considered a submit. Is there a way to test which
button was pressed to determine whether or not to run the script?
Thanks,
Aaron
P.S. I've already tried attaching the same script to the "Next" button's
onSubmit() handler, and when doing so, the script is apparently never run.
One way is to set a variable via each Submit button's onClick then test it.
<html>
<head>
<title>onsubmit.htm</title>
<script type="text/javascript">
var bool;
function submits() {
bool ? alert("Prev") : alert("Next");
}
</script>
</head>
<body>
<form action="" method="post" onsubmit="return submits()">
<input type="submit" name="Prev" value="<=" onclick="bool=true">
<input type="submit" name="Next" value="=>" onclick="bool=false">
<form>
</body>
</html>