ajax选中的复选框转数组传到后台
var selectedItems = new Array();
$(':input[class=ids][checked]').each(function() {
selectedItems.push($(this).val());
});
$.ajax({
type: "post",
url: "",
data: {items: selectedItems.join(',')},
async:false,
success: function(date){
if(date==1){
alert("选中的数据中存在已经上报的数据");
}
}
});
数据items 以字符串的形式传到后台
jsp中的checkbox怎么将选中的值传到后台
${list.fieldName}不共享
普通共享
按需共享
在循环列出的所有资源项中,将勾选的checkbox的值拼接成字符串传到后台:
function nextStep(){
var box = document.getElementsByName("apiContent");
var objArray = box.length;
var apiContentStr="";
for(var i=0;i
if(box[i].checked == true){
apiContentStr += box[i].value+",";
}
}
if(apiContentStr == "" || apiContentStr.length == 0){
alert("请勾选需要的资源项!");
return;
}
apiContentStr = apiContentStr.substring(0, apiContentStr.length-1);
$('#MainForm').attr('action', '${ctx}/api/toEditApply?apiContentStr='+apiContentStr);
$('#MainForm').submit();
}