How would i combined 2 html forms
I am trying to combined to forms that are in different position. so i can post all the data at once.
Here is a eg
<form action="actions.php">
<input type="text">
<input type="text">
<input type="submit" name="button" id="button" value="submit" />
</form>
<form>
<input type="text">
<input type="text">
</form>
Do NOT make 2 forms. Use proper HTML elements and CSS for layout. Feel free to use javascript to animate and add effects as needed.
By proper elements I mean you could do something like:
And use CSS to place them.
Of course, adapt the example to your needs.
I know how old this question is, but here is the answer anyway, using HTML5 Form attribute. (an attribute not a tag.)
Just make an id for your main form (i.e. id="main-form")
And in your other inputs (without using another form tag) put the new HTML5 form attribute (an attribute not a tag) with a value of your main form id (i.e. form="main-form").
* However It's not supported in IE
HTML lets you have other text and tags inside of a form. Just do this:
To be useful, your input tags need name attributes.
Use divisions and CSS, like this:
CSS can be used to position each part of your form.
Another option would be to use javascript, like this:
The inverse can also be done:
Just use a single
form
tag:All the form data will be submitted in one call (as you indicate is what you want in one of your comments) to
actions.php
.Note that this form (and the ones you posted in your question) are not very useful without any IDs on any of the input elements, as you will find it difficult to tell the values apart without one.
In regards to how the form look - you should use CSS to style and position the different elements.
If I'm not mistaken, you can put stuff in between the <input> entries in a <form>, if that's what you're worried about. Just make the form span the entire portion of the page which contains the inputs from what are currently two forms, and put the other non-form stuff inside the new <form>.