var checkedIds=""; //id
/**
*
* @return
*/
function changeIds(){
var oneches=document.getElementsByName("ids");
for(var i=0;i<oneches.length;iPP){
if(oneches[i].checked==true){
//
if(!contains(checkedIds,oneches[i].value)){
checkedIds+=oneches[i].value+",";
//console.log(oneches[i].value);
}
}
if(oneches[i].checked==false){
// idid
if(contains(checkedIds,oneches[i].value)){
checkedIds=checkedIds.replace((oneches[i].value+","),"");
}
}
}
}
/**
*
* @return
*/
function getChecked(){
if(checkedIds==""){
return;
}
var oneches=document.getElementsByName("ids");
for(var i=0;i<oneches.length;iPP){
//id
if(contains(checkedIds,oneches[i].value)){
oneches[i].checked="checked";
//console.log(oneches[i].value);
}
}
}
/**
*
* @param obj
* @param ele
* @return
*/
function contains(obj, ele) {
//console.log(obj);
//console.log(ele);
if(obj==""){
return;
}
/*obj*/
var arr = obj.split(",");
var i = arr.length;
while (i--) {
if (arr[i] == ele) {
return true;
}
}
return false;
}
onclick="changeIds();getChecked();contains("1","2");"
error message
Uncaught TypeError: Failed to execute "contains" on "Node": parameter 1 is not of type "Node".