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

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b2af-2c264.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b2af-2c264.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?