[Javascript] Passing form name to function
David Lovering
dlovering at gazos.com
Tue Sep 2 20:04:43 CDT 2003
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
>
>
More information about the Javascript
mailing list