[Javascript] Using onSubmit
pd
pd4953 at myrealbox.com
Tue Mar 12 10:36:14 CST 2002
What is the proper way to use onSubmit ?
I am trying to make it call a function that uses "confirm" to direct what
URL is called next. The following calls the function but always
loads tst2.html instead of staying with the current url if the user
presses "cancel".
<SCRIPT LANGUAGE="JavaScript">
<!-- // Activate cloak
function warn_update(msg, target){
if (confirm(msg))
{ var x = target;
window.location.href = x;
}
}
// Deactivate cloak -->
</SCRIPT>
<FORM method="post" action="tst2.html" onSubmit="warn_update('Are you
sure?',''tst2.html')">
<input type="submit" value="Submit" >
If I use a button type then I can make it stay with the current url but it
will not submit the input values of the form.
<FORM ...>
<INPUT TYPE="button" Value="New Button" onSubmit="warn_update('Are you
sure?','/tst2.html')">
Thank you.
Any input is much appreciated.
Paul
More information about the Javascript
mailing list