Check checkbox based on value

Hello,

I am trying to check a checkbox based on a value in the data model.

So if the field is 1, the check box needs to be checked. This is also in a detail table so it would need to apply to all records in that detail table.

You need to add the checked=“” in your input of type checkbox.

Lets say that you are doing it for all check box in a detail table AND there is as many checkbox as there is detail record…then

results.each(function(index){
    if(record.tables.detail[0].fields.yourField === 1){
        $(this).attr('checked',true);
    }else{
        $(this).attr('checked',false);
   }
};

or better

results.each(function(index){
    $(this).attr('checked',record.tables.detail[index].fields.yourField === 1);
};

How would I apply this to a specific id’ed checkbox for that particular line, because there are two for each detail table line?

I’d set a class to the the checkboxes I wan’t checked (or not) and use that class as the Selector of my script.