Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to combine html forms

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> 
like image 603
Rickstar Avatar asked Dec 11 '25 06:12

Rickstar


2 Answers

You can add hidden fields in the second form and fill these fields (using java script) with the first form values before submission.

like image 84
Artium Avatar answered Dec 14 '25 02:12

Artium


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

<form action="actions.php" id="main-form">
  <input type="text">
  <input type="text">
  <input type="submit" name="button" id="button" value="submit" /> 
</form> 


<input type="text" form="main-form">
<input type="text" form="main-form"> 
like image 41
Omar Salama Avatar answered Dec 14 '25 02:12

Omar Salama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!