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.
Even if you could get it to work in one browser, there's no guarantee that it would work the same in all browsers. So while you might be able to get it to work some of the time, you certainly wouldn't be able to get it to work all of the time.
Plain html cannot allow you to do this. But with javascript you can be able to do that. If you are using javascript/jquery you could classify your form elements with a class and then use serialize() to serialize only those form elements for the subset of the items you want to submit.
Then in your javascript you could do this to serialize class1 elements
For class2 you could do
For the whole form
or simply
You would even have problems making it work in different versions of the same browser. So avoid using that.
If you're using AngularJS, any
<form>
tags inside yourng-app
are replaced at runtime withngForm
directives that are designed to be nested.As Craig said, no.
But, regarding your comment as to why:
It might be easier to use 1
<form>
with the inputs and the "Update" button, and use copy hidden inputs with the "Submit Order" button in a another<form>
.Another way to get around this problem, if you are using some server side scripting language that allows you to manipulate the posted data, is to declare your html form like this :
If you print the posted data (I will use PHP here), you will get an array like this :
Then you can just do something like :
Your $_POST now has only your "main form" data, and your subform data is stored in another variable you can manipulate at will.
Hope this helps!