php 直接在 <table> 中使用 <input> 标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2139669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using <input> tags directly inside <table>
提问by RJD22
I'm generating a table with multiple editable rows. like a employee every row so that you can change multiple names at the same time. I have some hidden fields inside that also need to be looped with the table rows.
我正在生成一个包含多个可编辑行的表。像每一行的员工一样,以便您可以同时更改多个姓名。我里面有一些隐藏的字段,它们也需要与表行循环。
The problem is that having inputs inside table tags is not valid xhtml. And I don't want to wrap them inside <tr><td>tags since this would clearly make a new column for hidden fields that don't need one.
问题是在表格标签内输入是无效的 xhtml。而且我不想将它们包装在<tr><td>标签中,因为这显然会为不需要的隐藏字段创建一个新列。
Does someone know if I can wrap them inside something else to make it valid xhtml?
有人知道我是否可以将它们包装在其他东西中以使其有效 xhtml?
采纳答案by SLaks
You can put the hidden <input>s in an existing cell.
您可以将隐藏的<input>s 放在现有单元格中。
回答by Sampson
They're hidden, you can place them next to any visible input and be fine.
它们是隐藏的,你可以把它们放在任何可见的输入旁边,就可以了。
<tr>
<td><input type="text" name="fname" /></td>
<td><input type="text" name="lname" />
<input type="hidden" name="cid" value="11" />
<input type="hidden" name="uid" value="12" />
</td>
</tr>
回答by richsage
What's wrong with putting the hidden input tag in the final column?
将隐藏的输入标签放在最后一列有什么问题?
...
<td>
<input type="text" name="yourname" />
<input type="hidden" name="thisrowuniqueid" value="123" />
</td>
...
回答by Lark
I am not 100% sure if this will work or validate but you could try to set the containing rows and columns to visibility hidden.
我不是 100% 确定这是否有效或验证,但您可以尝试将包含的行和列设置为可见性隐藏。
tr.hidden, td.hidden {
visibility: hidden;
}
Worth a shot.
值得一试。
回答by Robert Cabri
this is perfectly valid XHTML strict code. It is possible to add input fields in table tags
这是完全有效的 XHTML 严格代码。可以在表格标签中添加输入字段
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dicabrio.com</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<form id="test" method="post" action="test.php">
<fieldset>
<legend>test</legend>
<table>
<tr><td>
<label>test</label><input type="text" name="test" value="" />
</td></tr>
</table>
</fieldset>
</form>
</body>
</html>

