tags:

views:

242

answers:

5

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?

+3  A: 

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

SLaks
yea I figured this too. I don't like the method tho because it breaks my formatting. Likely the is not other clean method so I will go with this for now.
RJD22
How does this break your formatting? The hidden `<input>` elements should have no effect on anything else.
SLaks
well not the output but I mean the source. (most likely I care about trivial things)
RJD22
+2  A: 

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>
Jonathan Sampson
A: 

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>
...
richsage
A: 

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.

Lark
visibility hidden just makes the element invisible but maintains the space they occupy .. so it would look 'weird'. display:none; would be better..
Gaby
A: 

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"&gt; 
<html xmlns="http://www.w3.org/1999/xhtml"&gt; 
<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>
Robert Cabri
I believe the problem is that they want to put the <input> tags after the <table> declaration, but **not wrapped** inside a row/column. Something like... <table> <input type="hidden" .../> <tr><td>stuff</td></tr> </table>If you absolutely *insist* on the doc validating, I'd put the hidden inputs in a hidden row and be done with it.
Civil Disobedient