douyicao2199 2013-10-23 08:46
浏览 5
已采纳

too long

i'm trying build a table that has a delete button for every entry, but the output is confusing me. The code is as follows:

                    if ($players != null) {

                        echo('<table class="playerTable">');
                        echo('<thead>');
                        echo('<tr>');
                        echo('<th> Last Name </th>');
                        echo('<th> First Name </th>');
                        echo('<th></th>');
                        echo('<th></th>');
                        echo('</tr></thead><tbody>');

                        for ($i=0; $i<count($players); $i++) {
                           printf('<form action="player.php" method="post" onSubmit="return submitCheck(\'%s\', \'%s\')">', $players[$i]->name, $players[$i]->surname);
                           echo("<tr>");
                           printf("<td> %s </td><td> %s </td>", $players[$i]->surname, $players[$i]->name);
                           echo('<td><input type="hidden" name="delete" value="'. $players[$i]->id .'"></td>');
                           echo('<td><input type="submit" value="Delete"></td>');
                           echo("</tr>");
                           echo('</form'); 


                        }
                        echo('</tbody></table>');
                    }

For some reason that i don't get, the produced output is as follows:

<tbody>
<form action="player.php" method="post" onsubmit="return submitCheck('someName', 'someName')"></form>
<tr>
    <td> someName </td>
    <td> someName </td>
    <td><input type="hidden" name="delete" value="1"></td>
    <td><input type="submit" value="Delete">
    </td>
</tr>

Which leads of course to the fact, that the submitCheck won't be executed - what am I missing here?

  • 写回答

2条回答 默认 最新

  • douhao6557 2013-10-23 08:48
    关注

    First of all, you shouldn't have a <form> tag within a <table>. Make it the other way around. Also, in your opening <form> tag, there's a missing = sign at the action attribute. The end tag of <form> should also be outside of the <table>.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据