if(fpids!="") {
zzdata = fpids.join(",");
}
if(fpnames!="") {
zzname = fpnames.join(",");
}
var t = document.getElementById(fid);
if(t.checked){
if(zzdata.indexOf(fid)==-1){
if(zzdata==""){
zzdata = fid;
zzname = frpname;
}else{
zzdata+=","+fid;
zzname += ","+frpname;
}
}
}else {
zzdata = zzdata+",";
zzname = zzname+",";
fid = fid+',';
frpname = frpname+',';
zzdata = zzdata.replace(fid,'');
zzname = zzname.replace(frpname,'');
}
if(zzdata.charAt(zzdata.length-1)==","){//判断最后一位是否是逗号
zzdata= zzdata.substring(0,zzdata.length-1);
}
if(zzname.charAt(zzname.length-1)==","){//判断最后一位是否是逗号
zzname= zzname.substring(0,zzname.length-1);
}
fpids=zzdata.split(",");
fpnames=zzname.split(",");
js处理字符串转数组,数组转字符串
最新推荐文章于 2022-10-25 10:39:47 发布