duankuaizhe8257 2018-07-25 21:31
浏览 99
已采纳

HTML表单:如何提交许多(100+)输入

I am working on a system that allows the user to preview the result as an HTML table. I put a checkbox in the leftmost cell that is checked by default. Should the user uncheck any row, that row will not appear in the final product.

Submitting this form, which as of now is only these checkboxes, with just HTML yields a 404 error. Removing or significantly reducing the number of the checkboxes fixes this problem.

I implemented name = "checkbox[]" instead of name = "checkbox1", name = "checkbox2", ... to see if that would solve the problem; it didn't.

I also tried serializing and submitting the form data with jQuery post and PHP, which still gives me the 404. I tried submitting the form using AJAX and jQuery to the same effect.

I'm not sure if submitting the data through $_SESSION will help. I don't know how I would implement this in my use case.

How can I submit many inputs without causing an error?

EDIT: A hopefully minimal, complete and verifiable example (using only HTML, since none of the scripting methods produced a better result):

<?
print "<form action = 'target.php' method='get'>";
for( $i = 0 ; $i < 200 ; $i++ ){
   print '<input type="checkbox" name="chk[]" checked /> Checkbox ' . $i . '<br />';
}
print '<input type="submit" value="Submit">';
?>

This produces the same error for me: 404.

  • 写回答

1条回答 默认 最新

  • douzhu7507 2018-07-25 21:59
    关注

    Replace <form action = 'target.php' method='get'> with <form action = 'target.php' method='post'>

    You use the GET method, which means that the input names and values will be sent in the URL. If you send data to the server, always use POST.

    If you have 100+ inputs, then the URL gets too long

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 github训练的模型参数无法下载
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐