Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-21-2010, 01:11 AM   PM User | #1
sheppardzwc
New to the CF scene

 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sheppardzwc is an unknown quantity at this point
Submit a "different" form onClick

Hi everyone,

Been struggling with this one all day - writing a vBulletin mod and am having trouble submitting a form. Yes, yes, I know, you submit forms with HTML, but a form instance is created before my form instance - something like:

<form name="main_form" etc>
<form name="my_form" etc>
<input button>
<input submit>
</form>

So I said, well, why not just do this:

Code:
<input type="submit" value="Order" onClick="document.my_form.submit()" /></form>

Yet apparently, no dice. Any help here guys?
sheppardzwc is offline   Reply With Quote
Old 08-21-2010, 01:37 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,549
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
HTML does *NOT* allow *NESTED* <form>s!!!!

You'll never get it to work with the <form>s as you showed.

You can have multiple <form>s on a page, but the second <form> *MUST* appear after the </form> of the first one, etc.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Old 08-21-2010, 01:52 AM   PM User | #3
sheppardzwc
New to the CF scene

 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sheppardzwc is an unknown quantity at this point
Quote:
Originally Posted by Old Pedant View Post
HTML does *NOT* allow *NESTED* <form>s!!!!

You'll never get it to work with the <form>s as you showed.

You can have multiple <form>s on a page, but the second <form> *MUST* appear after the </form> of the first one, etc.
Damn - any alternatives you could suggest?
sheppardzwc is offline   Reply With Quote
Old 08-22-2010, 01:54 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,549
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I just suggested one: Put your second <form> *AFTER* your first one.

Period.

If the fields of the two forms need to be intermixed on the page, then you *could* do it like this:
Code:
<form name="ONE">
<input name="ONE_name" />
<input id="TWO_name" onchange="document.TWO[this.id].value=this.value;" />
<input name="ONE_email" />
<input id="TWO_email" onchange="document.TWO[this.id].value=this.value;" />
<input type="button" id="TWO_submit" onclick="document.TWO.submit();"/>
... more fields for ONE ...
</form>
<form name="TWO" action="somethingElse.xxx">
<input type="hidden" name="TWO_name" />
<input type="hidden" name="TWO_email" />
</form>
But of course that only works if the user does not disable JavaScript.

Notice that the fields in ONE that are really meant to be part of TWO do *NOT* have names. They only have id's. Fields without names are *not* sent on to the form's action url.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:39 PM.


Advertisement
Log in to turn off these ads.