[Javascript] Passing form name to function

David Lovering dlovering at gazos.com
Tue Sep 2 19:57:50 CDT 2003


Easy enough to do.  Write a loop that scans the top document for FORM
objects, and then return a handle for each one found.  Handing back the name
will work of course, but the handle is typically what submit routines, etc.
need, so it makes work to deal with the name.

For example:

  <script language='JavaScript'>
  <!--
      var formArray = document.getElementsByTagName("FORM");
      for (var i=0; i<formArray.length; i++) {
        var formName = formArray[i].name;
        // do whatever you need to do //
        formArray[i].submit();
      }
  // -->
  </script>

Is a fairly brain-dead method.  Of course, you can also specify the
form-handler on the fly as well...

-- Dave Lovering

----- Original Message ----- 
From: "Clancy Jones" <clancyjones at hotmail.com>
To: <javascript at LaTech.edu>
Sent: Tuesday, September 02, 2003 5:43 PM
Subject: [Javascript] Passing form name to function


> 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>
>
> _________________________________________________________________
> Surf the net and talk on the phone with Xtra Jetstream @
> http://www.xtra.co.nz/products/0,,5803,00.html !
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>





More information about the Javascript mailing list