表格标签不会包含表格中的元素 [英] Form tag won't enclose elements inside a table
问题描述
< tr>
中有一个表单,但表单拒绝包装任何标签。我做了一个快速的JSFiddle 这是无效的,所以我的问题是我可以创建一个表格,它可以保存两个或多个 tr
s和任意数量的表内的其他元素吗?表中有其他行与表单没有关联,因此在整个表中放置一个< form>
是无益的,尽管看到其他行不会有任何输入的形式(POST请求),我想一个形式
可以放在整个表格中。 哪一个更好的解决方案;全表包装,还是一个工作解决方案,只需在表单
标签中包含所需的行?我知道我可以在 td>中放置一个
,但是在嵌套表中列宽不会相同,这就是为什么我来问这个问题。表
形式
除< thead> $ c之外,您不能打断
< table>
$ c>,< tfoot>
,< tbody>
,< tr>
,< th>
或< td>
。你需要在两个< td>
之间封装你的表单标签,或者你的整个< table>
需要被放置在< form>
标记内。
< table>
< tr>
< td>
< form>
...表单资料...
< / form>
< / td>
< / tr>
< / table>
..或..
<形式>
< table>
...
< / table>
< / form>
I've run into a curious problem; I've got a form inside a <tr>
, however the form refuses to wrap any tags inside it. I've made a quick JSFiddle here to play around with. Firebug reports that the form isn't wrapping anything:
The <form>
element is greyed out and not wrapping anything. The HTML for this test is below
<table>
<form>
<tr>
<td>Input</td>
<td>Another input</td>
</tr>
<tr>
<td colspan="4"><span>Other stuff</span></td>
</tr>
</form>
<tr>
<td>
Rows not affected by the form
</td>
</tr>
<tr>
<td>
Rows not affected by the form
</td>
</tr>
</table>
As can be seen, the form
holds two tr
s in the written markup. I read here that this is invalid, so my question is can I create a form that holds two or more tr
s and an arbitrary amount of other elements inside a table? The table has other rows in it not associated with the form, so putting a <form>
round the entire table is unhelpful, although seeing as the other rows won't have any inputs for the form (POST request), I suppose a form
could be put around the entire table.
Which is a better solution; whole-table wrap, or a working fix for just enclosing the needed rows in a form
tag? I know I could put a table
inside a td > form
, but then the column widths wouldn't be the same in the nested table, which is why I came to ask this question.
You cannot interrupt the <table>
structure with any tags besides <thead>
, <tfoot>
, <tbody>
, <tr>
, <th>
, or <td>
. You form tags need to be encapsulated between two <td>
or your entire <table>
needs to be placed within the <form>
tag.
<table>
<tr>
<td>
<form>
...form data...
</form>
</td>
</tr>
</table>
..or..
<form>
<table>
...
</table>
</form>
这篇关于表格标签不会包含表格中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!