表格内的表格 [英] Form inside a table

查看:34
本文介绍了表格内的表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 HTML 表格中包含了一些表单以添加新行和更新当前行.我遇到的问题是,当我在开发工具中检查表单时,我看到表单元素在打开后立即关闭(表单中不包含输入等).

I'm including some forms inside a HTML table to add new rows and update current rows. The problem that I'm getting is that when I inspect the forms in my dev tools, I see that the form elements are closed immediately after opening (inputs, etc are not included within the form).

因此,提交表单无法包含字段.

As such, submitting a form fails to include the fields.

表格行和输入如下:

<tr>
    <form method="post" action="">
        <td>
            <input type="text" name="job_num">
        </td>

        <td>
            <input type="text" name="desc">
        </td>
    </form>
</tr>

任何帮助都会很棒,谢谢.

Any help would be great, thank you.

推荐答案

表单是不允许tabletbodytr 的子元素.尝试在那里放置一个表单往往会导致浏览器将表单移动到它 之后出现在表格中(同时将其内容——表格行、表格单元格、输入等——放在后面).

A form is not allowed to be a child element of a table, tbody or tr. Attempting to put one there will tend to cause the browser to move the form to it appears after the table (while leaving its contents — table rows, table cells, inputs, etc — behind).

您可以在表单中放置整个表格.您可以在表格单元格内放置一个表格.表格中不能包含表格的一部分.

You can have an entire table inside a form. You can have a form inside a table cell. You cannot have part of a table inside a form.

在整个桌子周围使用一种表格.然后使用单击的提交按钮来确定要处理哪一行(快速)或处理每一行(允许批量更新).

Use one form around the entire table. Then either use the clicked submit button to determine which row to process (to be quick) or process every row (allowing bulk updates).

HTML 5 引入了表单 属性.这允许您为每行表格外提供一个表单,然后使用其id将给定行中的所有表单控件与这些表单之一相关联.

HTML 5 introduces the form attribute. This allows you to provide one form per row outside the table and then associate all the form control in a given row with one of those forms using its id.

这篇关于表格内的表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆