表格行标签中的表格

sid*_*com 11 html

formtr标签内写一个可以吗?

<table>
    % for my $word ( @$words_2 ) {
        <tr>
            <form action="/blacklist" method="post">
            <td><%=$word%></td>
            <td><input type="text" name="data" readonly hidden value="<%=$word%>" /></td>
            <td><input class="remove" type="submit" value="Remove" /></td>
            </form> 
        </tr>
    % }
</table>
Run Code Online (Sandbox Code Playgroud)

oez*_*ezi 10

tr 不允许form标签都有效直接孩子.大多数现代浏览器会让你做很多垃圾,所以你可以使用它 - 但我不会称之为OK.一个更好的方法是将完整的形式转换为tds之一(td允许文本,表单,内联和块元素作为子元素):

<table>
    <% for my $word ( @$words_2 ) { %>
        <tr>
            <td><%=$word%></td>
            <td>
              <form action="/blacklist" method="post">
                <input type="text" name="data" readonly hidden value="<%=$word%>" />
                <input class="remove" type="submit" value="Remove" />
              </form> 
            </td>
        </tr>
    <% } %>
</table>
Run Code Online (Sandbox Code Playgroud)

或者,更简单,只需使用一个链接(但注意data使用GET而不是POST- 也许你必须在代码中更改处理黑名单的内容):

<table>
    <% for my $word ( @$words_2 ) { %>
        <tr>
            <td><%=$word%></td>
            <td><a href="/blacklist?data=<%=$word%>">Remove</a></td>
        </tr>
    <% } %>
</table>
Run Code Online (Sandbox Code Playgroud)