form inside table
P粉916553895
2023-08-17 10:16:22
<p>I have included some forms in an HTML table for adding new rows and updating the current row. The problem I'm having is that when I inspect the form in the dev tools, I see that the form elements close immediately after opening (input boxes etc. are not contained within the form). </p>
<p>Therefore, the field cannot be included when submitting the form. </p>
<p>The table rows and input boxes are as follows:</p>
<pre class="brush:php;toolbar:false;"><tr>
<form method="post" action="">
<td>
<input type="text" name="job_num">
</td>
<td>
<input type="text" name="desc">
</td>
</form>
</tr></pre>
<p>Any help would be great, thank you. </p>
If you want to save your markup, use the "form" attribute :
(*Form fields outside the <form> tag)
A form is not allowed as a child element of
table
,tbody
ortr
. Attempting to place the form in these locations will cause the browser to move the form behind the table (while preserving its contents - table rows, table cells, input boxes, etc.).You can place the entire table within a form. You can place a form inside a table cell. But you cannot place part of a table inside a form.
Use a form around the entire table. The clicked submit button can then be used to determine which rows to process (to increase speed), or to process each row (to allow batch updates).
HTML 5 introduces
form
attribute. This allows you to provide a form for each row outside of the table, and then use itsid
to associate all form controls in a given row with one of the forms.