jeudi 12 décembre 2019

jQuery - disable checkbox if value match to elements in an array

i'm trying to disable checkboxes on page load but on a condition that the checkbox values match records in my database.

i found To disable the selective check box on page load jquery and http://jsfiddle.net/R27wq/1/. the only difference between his and my situation is the condition at which the checkbox is disabled. for his situation, if the value of the last column is equals to 1.0, the checkbox will be disabled.

i want to do the same except i want to make the checkbox disabled if its value match the records in my database.

below is my database:

my db

and below is a snippet of the code from my checkboxes:

<td>
   <input type="checkbox" class="seats" name="selected[]" value="A26">
</td>
<td>
   <input type="checkbox" class="seats" name="selected[]" value="A25">
</td>

the checkboxes look like this on the webpage: enter image description here

if the checkbox value match to the 'reserved' column, it should be disabled.

how do i implement the same concept for my situation? i was thinking maybe i could store the value from database in an array then from there, compare all the array elements to all the checkbox values? or is there a better way? can someone help me




Aucun commentaire:

Enregistrer un commentaire