Let's say I have a simple form, with a select combobox and a table that has a checkbox for each row, to choose the rows you want.
假设我有一个简单的表单,有一个选择的组合框和一个每行都有一个复选框的表,可以选择你想要的行。
Now, on the server-side, I need to associate all the items selected from the table (using the checkbox for each row), with the item selected in the combobox.
现在,在服务器端,我需要将从表中选择的所有项目(使用每行的复选框)与组合框中选择的项目相关联。
I know the value in the combobox will be submitted with the form, but how can I send all the selected elements from the table? do I have to use AJAX or something? or is it possible to do it via POST/GET?
我知道组合框中的值将与表单一起提交,但是如何从表中发送所有选定的元素?我必须使用AJAX或其他什么?或者可以通过POST / GET进行吗?
1 个解决方案
#1
1
The form needs to enclose (be an anscestor of) both the table and the combo box. The table row checkboxes should all look like
表单需要包含表和组合框(是它的一个anscestor)。表格行复选框应该都是这样的
<input type="checkbox" name="rows[]" value="ROW ID"/>
And then on the server side you'll get, in addition to the combobox value, $_POST['rows']
as an array containing the ids of the checked rows.
然后在服务器端,除了组合框值之外,你还可以获得$ _POST ['rows']作为包含已检查行的ID的数组。
#1
1
The form needs to enclose (be an anscestor of) both the table and the combo box. The table row checkboxes should all look like
表单需要包含表和组合框(是它的一个anscestor)。表格行复选框应该都是这样的
<input type="checkbox" name="rows[]" value="ROW ID"/>
And then on the server side you'll get, in addition to the combobox value, $_POST['rows']
as an array containing the ids of the checked rows.
然后在服务器端,除了组合框值之外,你还可以获得$ _POST ['rows']作为包含已检查行的ID的数组。