I can best describe this as follows:
I want this (entire table in editmode
and save button in every row).
<table>
<tr>
<td>Id</td>
<td>Name</td>
<td>Description</td>
<td> </td>
</tr>
<tr>
<td><input type="hidden" name="id" value="1" /></td>
<td><input type="text" name="name" value="Name" /></td>
<td><input type="text" name="description" value="Description" /></td>
<td><input type="submit" value="Save" /></td>
</tr>
<tr>
<td><input type="hidden" name="id" value="2" /></td>
<td><input type="text" name="name" value="Name2" /></td>
<td><input type="text" name="description" value="Description2" /></td>
<td><input type="submit" value="Save" /></td>
</tr>
<!-- and more rows here ... -->
</table>
Where should I put the <form>
tags?
You can't. Your only option is to divide this into multiple tables and put the form tag outside of it. You could end up nesting your tables, but this is not recommended:
I would remove the tables entirely and replace it with styled html elements like divs and spans.
If you try to add a form warping a tr element like this
some browsers in the process of rendering will close form tag right after the declaration leaving inputs outside of the element
something like this
This issue is still valid for warping multiple table cells
As stereoscott said above, nesting tables are a possible solution which is not recommended. Avoid using tables.
It's worth mentioning that this is possible in HTML5, using the "form" attribute for input elements:
While clean in its lack of JS and use of original elements, unfortunately this isn't working in IE10.
You just have to put the
<form ... >
tag before the<table>
tag and the</form>
at the end.Hopte it helps.
I'd say you can, although it doesn't validate and Firefox will re-arrange the code (so what you see in 'View generated source' when using Web Developer may well surprise). I'm no expert, but putting
just ahead of the
and then using
at the end of the row certainly gives the functionality (tested in Firefox, Chrome and IE7-9). Working for me, even if the number of validation errors it produced was a new personal best/worst! No problems seen as a consequence, and I have a fairly heavily styled table. I guess you may have a dynamically produced table, as I do, which is why parsing the table rows is a bit non-obvious for us mortals. So basically, open the form at the beginning of the row and close it just after the end of the row.
Im late to the party, but this worked great for me and the code should explain itself;
HTML: