=$("input[type='checkbox']:checked").each(function(){
arr_v.push(this.val());
});
arr_v.join(',');
即可以了
代码如下:
//此为重点,该句与下面的第一句效果一样
var selectedItems = new Array();
$("input[@name='itemSelect[]']:checked").each(function() {selectedItems.push($(this).val());});
if (selectedItems .length == 0) 下拉框 var s = $("#parentId").find("option:selected").val();
alert("Please select item(s) to delete.");
else
$.ajax({
type: "POST",
url: "/ajax_do_something.php",
data: "items=" + selectedItems.join('|'),
dataType: "text",
success: function (request) {
document.location.reload();
},
error: function(request,error){
alert('Error deleting item(s), try again later.');
}
}
);
java 拆分
代码如下:
String names = null;
String name1 = null;
String name2 = null;
names = request.getParameter("names");
String[] name = names.split(",");
for(String x : name){
if("zhangsan".equals(x)){
name1 = x;
}
if("lisi".equals(x)){
name2 = x;
}
}
jquery 修改时候选中 后台查询的复选框
代码如下:
var struids='${useridstr}'; //后台获取数据
alert(struids);
if(struids!='')
{
var str=struids.split(",");
for(var j=0;j
$(":checkbox[value='"+str[j]+"']").attr("checked",true);
}
}
代码如下:
var module='${module}'
$("#module option[value='" + module + "']").attr("selected","selected");