lundi 15 juillet 2019

How to update checkbox props value based on database data using ajax?

I'm trying to load all checkboxes based on a list of data ('active/inactive') from the database.

success:function(data){
    for(j=1;j<=array.length;j++){
         if(data[j-1] == "active"{
               $('#day'+i+'-hours'+j)+prop("checked",true).checkboxradio("refresh");
         }else{
               $('#day'+i+'-hours'+j)+prop("checked",false).checkboxradio("refresh");
         }
    }
}

the ajax is inside a nested loop, I'm trying to show the value for 10 timer list, inside a 6 different models representing days. its probably not the most efficient way to do it, but how do i can properly update the checkboxes?




Aucun commentaire:

Enregistrer un commentaire