我在 HTML
中创建行从MySQL
动态表PHP
中的值环形。每行代表 MySQL
中的一行并通过 id 进行识别。
我希望能够拥有 <input type='checkbox'>
在每一行上,并在底行有一个“删除所选行”按钮。
我的问题是我应该如何POST
所选的复选框以及如何在 PHP
中识别它们- 文件。
我有这个脚本serialize
<input type='text'>
字段:
function serealizeInputs (input)
{
var array = [];
input.each(function(){ array.push($(this).val()) });
return array;
}
var value = serealizeInputs($('.my_input_field'));
如何为复选框编写类似的内容?
正如你所见,我对此还很陌生。如果您需要查看更多代码,请告诉我。
最佳答案
您可以使用prop attribute检查复选框是否被选中。这是live demo
function serializeCheckboxes(input)
{
var array = [];
input.each(function(){
if($(this).prop("checked"))
{
array.push($(this).attr("id"))
}
});
alert(array);
return array;
}
关于php - jQuery 序列化从 MySQL 动态创建的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13415026/