2 forms on one html page - how?

i have one form which spans from the top of my page to the bottom and within that another small form. prob is when i have them both on the same page and u hit either submit button, its not posting the right action. ie: form 1 on submit posts to the address of form 2. what tags would i put in to make sure they go to the correct urls of each.

big form

<form method="post" action="http://www.dfg/order.asp" onsubmit="return validateForm(this)" id=form1 name=form1>

small form within above form tags

<form action="mailinglist.cgi" method="post">
  <input type="hidden" name="action" value="subscribe">

pls show exactly where code goes. thanks.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

u may rename the submit button, see if it helps.


<form name=bigForm>
<form name=inForm>
<input type=submit name=iSub value=submit>
<input type=submit name=bSub value=submit>
I haven't tested this code, but I think it should do the trick:  note that you use input type=button and not input type=submit.

<script language=Javascript>
function submitThis(whichOne)
  else if(whichOne =='inner')
<form method="post" action="http://www.dfg/order.asp" onsubmit="return validateForm(this)" id=form1 name=form1>
<input type="button" name="goForm1" value="Submit Outer" onClick="submitThis('outer');">
<!--use input type=button instead of input type submit for both forms-->
<form action="mailinglist.cgi" name=form2 method="post">
  <input type="hidden" name="action" value="subscribe">
  <input type="button" name="goForm2" value="submit" onClick="submitThis('inner');">

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

so you're saying that the small form is WITHIN the bigger form?
in that case, the action of the smaller form overrides that of the larger form.

you should not put another form inside a form (i.e. nesting)...
you should separate your forms...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
> in that case, the action of the smaller form overrides that of the larger form.

Ummm....... No.

In that case the behaviour is undefined, because forms cannot contain other forms. Period.

Check the HTML spec:

  <!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->

(Translation for those of you who don't speak DTD: "FORM may contain block elements and/or SCRIPT blocks. It may not contain other FORM elements.")

So it's not a case of "should not nest", it's a case of "MUST not nest".
Well you heard it from Zontar,

you can't do that.

But if your problem exists because you need your 'outer' form spanning most of the page,  you could probably split it into multiple forms and collect them into then submit the merged one.  

I just tested this script and it seems to work by adding all the elements to the first form tag.  This may 'ugly up' your page on submit though.  


--code as follows--

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<TITLE> New Document </TITLE>
function makeAndSubmitTheBigForm()
//form[0] will be the big form....

var elementCounter=0;

  //start at form[1] and add all elements to form[0]
  for ( var loop1=1; loop1 < document.forms.length; loop1 ++)
      for ( var loop2=0; loop2 < document.forms[loop1].elements.length; loop2 ++)
                 //increment element counter

                 //add the element to form[0]


<form action="none" method="get">

<form name=1>
<input type=text name=abc value="WOW">
<form name=2>
<input type=text name=def value="WOW">
<form name=3>
<input type=text name=ghi value="WOW">

<input type=button name=click value=click onclick="makeAndSubmitTheBigForm();">

Another possibility might be the creative use of CSS positioning.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.