Is it possible to nest html forms like this
<form name="mainForm">
<form name="subForm">
</form>
</form>
so that both forms work? My friend is having problems with this, a part of the subForm
works, while another part of it does not.
Is it possible to nest html forms like this
<form name="mainForm">
<form name="subForm">
</form>
</form>
so that both forms work? My friend is having problems with this, a part of the subForm
works, while another part of it does not.
The second form will be ignored, see the snippet from WebKit for example:
While I don't present a solution to nested forms (it doesn't work reliably), I do present a workaround that works for me:
Usage scenario: A superform allowing to change N items at once. It has a "Submit All" button at the bottom. Each item wants to have its own nested form with a "Submit Item # N" button. But can't...
In this case, one can actually use a single form, and then have the name of the buttons be
submit_1
..submit_N
andsubmitAll
and handle it servers-side, by only looking at params ending in_1
if the name of the button wassubmit_1
.Ok, so not much of an invention, but it does the job.
I ran into a similar problem, and I know that is not an answer to the question, but it can be of help to someone with this kind of problem:
if there is need to put the elements of two or more forms in a given sequence, the HTML5
<input> form
attribute can be the solution.From http://www.w3schools.com/tags/att_input_form.asp:
Scenario:
Implementation:
Here you'll find browser's compatibility.
In a word, no. You can have several forms in a page but they should not be nested.
From the html5 working draft:
Today, I also got stuck in same issue, and resolve the issue I have added a user control and
on this control I use this code
and on PreRenderComplete event of the page call this method
I believe this will help.
A simple workaround is to use a iframe to hold the "nested" form. Visually the form is nested but on the code side its in a separate html file altogether.