Re: 'Lost' function return value: what am I doing wrong?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: 'Lost' function return value: what am I doing wrong?

From: Michael Winter <m.winter@blueyonder.co.uk>
Date: Mon Jan 09 2006 - 17:22:51 CET

On 09/01/2006 08:12, bdobby@fish.co.uk wrote:

[snip]

> I have a form with an onsubmit event handler:
> <form id="uploadForm" method="post" action="..."
> onSubmit="checkDates()">
>
> The event handler does some minor validation, then returns true or
> false:

The onsubmit attribute defines - internally - another function. It is
equivalent to:

   document.forms.uploadForm.onsubmit = function(event) {
     checkDates();
   };

As this function does not have a return statement, its result will
always be the Undefined value (undefined).

   <form id="uploadForm" ... onsubmit="return checkDates();">

[snip]

> form.onsubmit = function(){MyClass.onsubmit(listId);};

A similar thing occurs here; the return value of that call must be
returned from the calling function:

   form.onsubmit = function() {return MyClass.onsubmit(listId);};

[snip]

Hope that helps,
Mike

-- 
Michael Winter
Prefix subject with [News] before replying by e-mail.
Received on Tue Jan 17 17:06:11 2006