[Javascript] Generic submit

Ian Skinner ian.skinner at bloodsource.org
Fri Jan 7 17:34:43 CST 2005


Yup...something like this:  onclick("this.parentElement.submit());" you will need as many parenElement segments as there are nodes between the anchor tag and the form tag.

OR maybe better: onclick("document.getElementById("formID").submit());"


--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

"C code. C code run. Run code run. Please!"
- Cynthia Dunning



...-----Original Message-----
...From: Alan Gardner [mailto:gardner.alan at gmail.com]
...Sent: Friday, January 07, 2005 3:28 PM
...To: [JavaScript List]
...Subject: Re: [Javascript] Generic submit
...
...Nothing special, or what I'd consider out of typical xhtml usage, but
...here it is.
...
...Ideally, I'd like to get away with something like this:
...<a href="#" onClick="this.form.submit()" class="button">Submit</a>
...
...I think the issue with this is that the <a> is not a DOM child of
...<form>, so any usage of the "this" keyword wouldn't return the form
...object when used in the <a> tag.
...
...So, unless prove wrong, I'm thinking that the only way to generically
...submit using an anchor tag is to somehow traverse up the node tree
...until I find the <form> and get its name value.
...
...
...
...
...On Fri, 07 Jan 2005 17:55:55 -0500, Shawn Milo <ShawnMilo at runbox.com>
...wrote:
...> Please send your form declaration, and any other parts
...> you think are relevant.
...>
...> Shawn
...>
...> Alan Gardner wrote:
...>
...> >I thought it looked good, but my javascript console says "Error:
...> >this.form has no properties". I've checked and the link is inside the
...> >form tag. Suggestions?
...> >
...> >
...> >On Fri, 07 Jan 2005 15:58:51 -0500 (EST), Shawn Milo
...> ><ShawnMilo at runbox.com> wrote:
...> >
...> >
...> >>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
...> >>>
...> >>>
...> >>>
...> >>_______________________________________________
...> >>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
...> >
...> >
...> >
...> >
...>
...> _______________________________________________
...> 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

Confidentiality Notice:  This message including any
attachments is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the
intended recipient, please contact the sender and
delete any copies of this message. 





More information about the Javascript mailing list