[Javascript] Using onSubmit
pd
pd4953 at myrealbox.com
Tue Mar 12 11:31:45 CST 2002
I found the answer to this.
<script>
function confirm_update(msg){
return(confirm(msg)?true:false);
</script>
<FORM ACTION="tst2.html" method=post
onsubmit="return(confirm_update('Are you sure'?))">
<input type="text" name="testfld">
<input type="submit" value="Submit" >
</form>
Thanks,
Paul
At 11:36 AM 3/12/2002 -0500, you wrote:
>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
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list