jeudi 5 décembre 2019

how to make a checkbox selected from the database

how to make a checkbox selected if the data in the database is yes or not, I tried with the attr function but that didn't work

 if(data[1].grace == 'yes'){
                              console.log('this is yes');
                              $("#grace").attr("checked",true);

                          }else{
                             console.log('this is no');
                          }

this my html

<div class="string-check string-check-bordered-primary mb-2">
                                <input type="checkbox" name="grace" class="form-check-input" id="grace">
                                <label class="string-check-label" for="grace">
                                    <span class="ml-2" for="grace"></span>
                                </label>

                            </div>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire