tags:

views:

115

answers:

8

Whether we can have a form inside another form?. Is there any problem with that.

A: 

Yes there is. It is wrong. It won't work because it is wrong. Most browsers will only see one form.

http://www.w3.org/MarkUp/html3/forms.html

Alexander
The HTML 3 spec isn't a very good one to link to — it died without reaching Recommendation status.
David Dorward
Why link to an old spec? The Html 3.0? There are newer specs...
Oded
This one is the only one that specifies at the beginning of the description about this interdiction (and one of the first Google Search results). In other cases I've only seen forum discussions about HTML4 and XHTML leading to the same results. One forum post even said something about HTML4 allowing this, though I never heard about it and couldn't find any examples or proof.
Alexander
Alexander
@Alexander — "This one is the only one that specifies at the beginning of the description about this interdiction" — err? I linked to two others in my answer.
David Dorward
What's the point? The right answer was the one which had absolutely no justification whatsoever.I am beginning to doubt the effectiveness of participating in this.
Alexander
+5  A: 

No. HTML explicitly forbids nested forms.

From the HTML 5 draft:

Content model: Flow content, but with no form element descendants.

From the HTML 4.01 Recommendation:

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

(Note the -(FORM) section).

David Dorward
+1, didnt see it was already linked
Gordon
+2  A: 

Though you can have several <form> elements in one HTML page, you cannot nest them.

Oded
A: 

Not recommended.

Bikal Gurung
not only is it not recommended, it's wrong.
jordanstephens
+1  A: 

The following post has your answers and alternative ways for redesign:

http://stackoverflow.com/questions/597596/how-do-you-overcome-the-html-form-nesting-limitation

Ankit Jain
A: 

Each form submits elements between form tags, and reset functions like...

If you try to nest them, each form and their related elements will have problem about submittimg the right data.

So it is not allowed. Depending what you wish to do, you can use if else tags to create diffrent form tags like:

if SomeData:
    <form submit='a.php'>
else:
    <form submit='b.php'>
{{form elements}}
</form>
FallenAngel
A: 

It's not valid XHTML to have to have nested forms. However, you can use multiple submit buttons and use a serverside script to run different codes depending on which button the users has clicked.

Martin LeBlanc
A: 

That (nested forms) is a not a nice practice. You will not get what you expect to be, though HTML or server side scripts might not warn you doing that.

Why you want to use nested forms? Use multiple forms rather.

.. ...

You can easily manipulate with multiple form objects using Javascript. Check this nice article to know more about how to access form objects in case of multiple forms.

PradeepKr