[Javascript] Generic submit

Shawn Milo ShawnMilo at runbox.com
Fri Jan 7 14:58:51 CST 2005


Something like document.forms[0].submit(); should work, but, 
of course, it would only submit the first form. 

Also, maybe -- wait!

Try this:
document.forms[this.form.id].submit();

If your XHTML is good, and you have ids for all of 
your forms, I think that this should work.

Shawn.

> Hi all,
> If I want to use an anchor link to submit a form, but may not know the
> name of the form, or how many forms are on the page, how would I best
> do that?  I initially thought a simple <a href="#"
> onclick="this.form.submit()"> would work, but it  appears only to work
> on an input tag.  Any suggestions on how to create a generic submit
> link that I can throw into any page without additional scripting?
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 



More information about the Javascript mailing list