【发布时间】:2015-06-02 04:02:10
【问题描述】:
我有以下代码,用于显示图像及其复选框。它是启用还是禁用
if($ring["status"] != '1')
echo '<td><input type="checkbox" name="ringIds[]" value="'.$ring["id"].'">'
. '<input type="image" onClick="openGalleryRing(\''.$ring['imagePath'].'\', \''.$ring['id'].'\');" src="http://thevowapp.com/iphoneapp/vowstore/rings/'. $ring['imagePath'] .'" name="checked" value="' . $ring['id'].'" data-my-info="'. $ring['ringSetName'] .'" style="width:200px; height:200px; margin-left: 10px;"></td>';
else
echo '<td><input type="checkbox" checked="checked" name="ringIds[]" value="'.$ring["id"].'">'
. '<input type="image" onClick="openGalleryRing(\''.$ring['imagePath'].'\', \''.$ring['id'].'\');" src="http://thevowapp.com/iphoneapp/vowstore/rings/'. $ring['imagePath'] .'" name="checked" value="' . $ring['id'].'" data-my-info="'. $ring['ringSetName'] .'" style="width:200px; height:200px; margin-left: 10px;"></td>';
在我的 javascript 中,我正在使用类似
的东西$('.updateBtn').on('click', function()
{
var checked = $('input[name="ringIds[]"]:checked').serialize();
if(checked !== '')
window.location.href = 'actions.php?j=24&' + checked;
else
alert('No Rings are selected');
});
这行得通,我可以获得所有选中的复选框,但我真正想要的是获得所有复选框列表,这些复选框已选中,哪些未选中。我该如何修改此代码?
【问题讨论】:
-
如果你得到所有选中和未选中的元素,你怎么知道哪些被选中
-
var checked = $('input[name="ringIds[]"]').serialize();
标签: javascript php jquery html