dtkvlj5386 2015-06-02 14:21
浏览 121
已采纳

如何在具有多行并且动态构建的数据表中提交表单?

Ok, I really am not that good at submitting questions here, so if I don't get all the markup just right, go easy on me. I am building a form that contains rows of data, of which a couple of the fields are inputs, and the rows all contain matching data. That is, each row contains the same fields. This is the html for my form...

echo "<div id='display-wrapper' style='position:absolute;
    left:-100000px;'><form method='post'><table id='uploan' class='table-striped table-bordered'><thead><tr>";
        $TtlReactHeaderNames = array_keys($TtlReactQuery[1]);
        foreach($TtlReactHeaderNames as $TtlReactkey=>$TtlReactvalue) {
            echo "<th>" . $TtlReactvalue . "</th>";
        }    
        echo "<th class='green'>Revised BB Value</th><th class='green'>Revised Max Loan Capacity</th></tr></thead><tbody>";
        foreach($TtlReactQuery as $TtlReactkey=>$TtlReactvalue) {
            echo "<tr>";
            echo "<td>" . $TtlReactvalue['Store Name'] . "</td>";
            echo "<td>" . $TtlReactvalue['VIN Number'] . "</td>";
            echo "<td><input type='text' name='display-name' value='" . $TtlReactvalue['Full Name'] . "' readonly /></td>";
            echo "<td>" . $TtlReactvalue['SSN(Last Four)'] . "</td>";
            echo "<td>" . $TtlReactvalue['Ecash Vehicle Value'] . "</td>";
            echo "<td>" . $TtlReactvalue['Max Capacity'] . "</td>";
            echo "<td><input type='text' name='revised-bb-value' /></td>";
            echo "<td><input type='text' name='revised-max-loan-capacity' /></td>";
            echo "</tr>";
        }
        echo "</tbody></table><input type='submit' /></form></div>";

...and there are about 200 rows of data in this form. The end user will only be choosing one row, filling the info in the fields that are blank, and submitting it. But as it is right now, it will only submit what is on the last line due to the fact that all the rows input's have the same name. I thought of adding a counter and appending the name attribute with the number so that each field has a unique name, but I end up with a BUNCH of empty fields in the POST array when I submit it, although the data is there too, and I don't know what row they are going to fill out so i don't know what to grab from the POST data. Someone suggested a hidden form using javascript to populate the form but I'm not exactly sure how to go about it. Any help would be so appreciated!!!

  • 写回答

3条回答 默认 最新

  • dtczp02204 2015-06-02 14:49
    关注

    By creating one big form you will need to use different names for every field. A better solution would be to create on form per row of data. This way you will have many forms with the same fields but only one will be sent.

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

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效