你可以有一个逻辑< form>拆分多个< div>? [英] Can you have a single logical <form> split across multiple <div>s?
问题描述
在我现有的网页布局中,包含多个文件,一个指定高层布局,有两个元素,一个用于左列,另一个用于右列。
In my existing web page layout, which involves multiple files, one specifying the high-level layout, there are two elements, one for a left column, and one for a right column.
我想拥有一个逻辑< form>
(只需一个动作),其中< input>
元素分布在左列和右列。唯一能做到这一点的方式是将元素作为< div>
s的父项(并重构我的布局代码),还是可以像< form [something]>
,这样点击一个表单提交就可以提交来自两个表单的所有输入了吗?
I want to have a single logical <form>
(with a single action) where <input>
elements are spread across both the left column and the right column. Is the only way to do this have the element be parent to both <div>
s (and refactor my layout code), or is it possible to do something like <form [something]>
inside both divs, so that clicking submit in one form submits all the inputs from both forms?
推荐答案
提交这两种表单的唯一方法是在一个< div>
>< form> 标签。或者,您可以使用jQuery / JavaScript来汇总数据并将它们作为一个提交进行提交。
The only way to submit both forms is to wrap both <div>
s within a single <form>
tag. Or, you can use jQuery/JavaScript to aggregate the data and submit them together as one submission.
这篇关于你可以有一个逻辑< form>拆分多个< div>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!