在桌子里面 [英] Form inside a table

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

问题描述

我在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.

表格行和输入如下:

The table row and inputs are as follows:

<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.

推荐答案

表单是不允许是子元素a 表, tbody tr 。尝试放置一个会导致浏览器将表单移动到表格后(在保留其内容 - 表格行,表格单元格,输入等)的同时,它会显示

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).

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

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