[Javascript] Passing form name to function

Clancy Jones clancyjones at hotmail.com
Tue Sep 2 20:08:42 CDT 2003


Thanks Dave, that's exactly what I needed!
Clancy


>From: "David Lovering" <dlovering at gazos.com>
>Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
>To: "[JavaScript List]" <javascript at LaTech.edu>
>Subject: Re: [Javascript] Passing form name to function
>Date: Tue, 2 Sep 2003 18:04:43 -0700
>
>Hmmm... try the following
>
>function postForm(formName) {
>      if (formName == "") { return -1; }
>      eval('document.' + formName + '.submit()');
>}
>
>presuming of course you check to make sure the form actually exists, etc.
>
>I use this method all the time, and it has yet to bite me in the butt.
>
>-- Dave Lovering
>
>P.S:  A slightly more "artsy" method --
>
>   function postForm(formName) {
>       if (formName == "") { return -1; }
>       document.forms[formName].submit();
>   }
>
>   All this presumes too that the "action" elements are correctly 
>defined...
>
>
>
>----- Original Message -----
>From: "Clancy Jones" <clancyjones at hotmail.com>
>To: <javascript at LaTech.edu>
>Sent: Tuesday, September 02, 2003 5:51 PM
>Subject: [Javascript] Passing form name to function
>
>
> > Apologies, my whole question is...
> >
> > Hi all, I have a page with several forms on it.  I want to have a 
>generic
> > javascript function for submitting them after validation.
> >
> > eg.
> > <script language="JavaScript">
> > function postForm(formName){
> > document.formName.submit();
> > }
> > </script>
> >
> > Then within a particular form I have a button eg:
> > <input name="Qsearch" type="button" value="Search"
> > onClick="postForm('nameOfThisForm');">
> >
> > At the moment this is giving me an error:
> > document.formName is null or not an object.
> >
> > Can someone help me out with the right syntax for this?
> >
> > TIA,
> > Clancy
> >
> > _________________________________________________________________
> > Download MSN Messenger @  http://messenger.xtramsn.co.nz   - add your
> > friends!
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> >
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript

_________________________________________________________________
Gaming galore at  http://xtramsn.co.nz/gaming !




More information about the Javascript mailing list