[thelist] Submitting a form with javascript

John Corry lists at neoncowboy.com
Tue Nov 4 02:11:54 CST 2003


 
> excellent.
Yes, it is.

> then he's left with a link that no longer does what he 
> expects.

And a submit button that does exactly what he expects, and an enter key that
also submits the form.

> any reason you can't just move the <form> and </form> tags in 
> order to encompass this optional link?

Yes, well...not 'can't', but there are reasons it's difficult and
impractical.

All of the pages in the site, including the admin section, are generated by
php. Common page elements (navigation, header, footer) are returned by php
functions (which work similarly to includes). I'm afraid that conditionally
writing the <form> tag on the page where it will be used (which is what will
be required to place it outside of the main content <td>) would just make
the code difficult to read and understand.

It's a lot cleaner to keep the <form> tag where there's a form.

> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > I don't need the onSubmit event.
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> 
> no, but when you do.  time to re-engineer.

OK, yes.
If I ever use the onSubmit handler, I'll have to reengineer.
 
> this is avoidable though.  don't use the submit() method.  
> instead, call a
> click() event on the submit button when the link is clicked.

Wait...what?
I can do:
Document.formName.submitInputButtonName.click() ? And that acts the same as
the submit button being clicked?

How's that work?

I didn't know I could do that.

John




More information about the thelist mailing list