I has a table with columns name 1."has_kul_01" until "has_kul_100" 2. "has_ph_01" until "has_ph_100" I am using JSON ajax to perform this. If the data return from mySql="1" then it will check the checkbox. So i wanna loop through ONLY "has_kul_01" columns but i have no ideas how to do.
function getAgentExpertiseArea(user_id) {
$.ajax({
url: "controller/xx.php",
type: "POST",
data: {
action: 'getXX',
user_id: user_id,
},
success: function (response) {
var resp = JSON.parse(response);
if(resp != null) {
if(resp.has_kul_01==1){
$("#has_kul_01").prop( "checked", true);
}
}
}
});
}
If works fine with Else statement. But i would like to do in Loop so that i do not need to write 100 times if else statement.
AND THIS IS MY HTML
<div class="col-12 col-lg-4 pb-2 px-0">
<div class="row align-items-center">
<input type="checkbox" id="has_kul_01" name="has_kul_01" value="has_kul_01" >
<label for="has_kul_01" class="ml-2 mb-0">KUL 01</label>
</div>
Thanks for your help