P粉8262835292023-08-18 09:21:48
If you want to save your markup, use the "form" attribute :
<form method="GET" id="my_form"></form> <table> <tr> <td> <input type="text" name="company" form="my_form" /> <button type="button" form="my_form">ok</button> </td> </tr> </table>
(*Form fields outside the <form> tag)
P粉4594409912023-08-18 00:22:45
A form is not allowed as a child element of table
, tbody
or tr
. 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 its id
to associate all form controls in a given row with one of the forms.