how to combine html forms

2019-05-30 04:44发布

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> 

10条回答
戒情不戒烟
2楼-- · 2019-05-30 05:12

With javascript you can grab all the form elements and combine them all into the same form and submit them at the same time. Is that kind of what you're looking for?

查看更多
Rolldiameter
3楼-- · 2019-05-30 05:13

I do not know your actual requirement but it is advisable and standard practice(as what I know) to have one form and put the elements into that.. may be position them inside div/table/css etc. Then by using javascript you can get the control values. e.g:

document.getElementById("controlid").value

or

document.forms[0].Element[0].value    
document.forms[1].Element[0].value

hope this will give some idea

查看更多
beautiful°
4楼-- · 2019-05-30 05:16

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

查看更多
萌系小妹纸
5楼-- · 2019-05-30 05:16
<form action="actions.php">
<input type="text">
<input type="text">
<input type="text">
<input type="text">

 <input type="submit" name="button" id="button" value="submit" />

</form> 

Now they are combined.

查看更多
登录 后发表回答