Js function call

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".
Sep.12,2021

Don't write that, it's recommended by not , and it's prone to a lot of problems.

write in html:

 
you can complete this second code

when I see onclick, I guess you are executing methods in html tag style. If so, it is not recommended that you should also support multiple event methods in HTML tags. You can write them as above

.
Menu