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

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决