[Javascript] multiple onSubmit events not working

Nick Fitzsimons nick at nickfitz.co.uk
Thu Sep 1 06:26:00 CDT 2005


>
> I'm attempting to clear three functions with a single onSubmit form event.
>
> <form name="form" action="dothis.php" method="post" onSubmit="return
> check_upload_required(); openpopup(); submitonce(this);">
>
> The check_upload_required function works as expected but the script never
> executes the openpopup() or submitonce(this) functions. If I remove the
> check_upload_required() from the onSubmit event the other functions work
> as expected. Can anyone shed some light on why this is happening. I really
> need for all three functions to work together.
>


When you use "return check_upload_required;" it does exactly that -
returns with the value that came back from the function, and therefore
stops processing any code after that point.

Try defining a single function:

function submitHandler(theForm) {
   var result = check_upload_required;
   if (result) {
      openpopup();
      submitonce(theForm);
   }
   return result;
}

and change the handler to

onsubmit="return submitHandler(this);"

HTH,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/





More information about the Javascript mailing list