Using <input> tags directly inside

2019-06-16 18:26发布

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.

Does someone know if I can wrap them inside something else to make it valid xhtml?

标签: php html xhtml
5条回答
聊天终结者
2楼-- · 2019-06-16 19:06

You can put the hidden <input>s in an existing cell.

查看更多
干净又极端
3楼-- · 2019-06-16 19:15

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>
查看更多
Animai°情兽
4楼-- · 2019-06-16 19:16

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>
...
查看更多
▲ chillily
5楼-- · 2019-06-16 19:29

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.

tr.hidden, td.hidden {
    visibility: hidden;
}

Worth a shot.

查看更多
家丑人穷心不美
6楼-- · 2019-06-16 19:32

this is perfectly valid XHTML strict code. It is possible to add input fields in table tags

    <!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>
查看更多
登录 后发表回答
向帮助了您的知道网友说句感谢的话吧!