HTML and CSS Reference
In-Depth Information
Each form control element ( button , input , and so on) also has an attribute called
form , which can be used to associate a form control element with a form that is differ-
ent from the one it is contained in within the HTML structure. This is perhaps clearer if
viewed through some example code:
<form id="form1">
<p><button type="submit">Submit!</button></p>
<form id="form2">
<p><input name="example" form="form1 form2" /></p>
<p><button type="submit">Submit!</button></p>
In this case, the input element with the name example has its form attribute set
to the value form1 form2 , which means it is treated as if its containing forms were
form1 and form2. When either form is submitted, the example input control will be
submitted as well. In this way, the form attribute can be used to simulate a nested form,
even though that structure is not allowed in HTML. The form attribute can also be set
on submit buttons so that one submit button can submit another form. This feature could
be used if, for example, you had a search field in the header and footer of your page and
you wanted both search inputs to be submitted to the same form. Instead of putting the
whole page content inside the form (which would prevent creating additional forms on
the page), the header and footer submit controls can be associated with the same form.
Note Like with other contemporary form features, Opera is ahead of the pack on this
one. Be sure to test this feature in your preferred browser, but don't be surprised if it
isn't implemented yet!
Search WWH ::

Custom Search