vendredi 24 juin 2016

checkbox checked with php on page load

I am new in programing and stuck at a point. I am using an API which returns multiple values in an array. I get these values in a form which contain check boxes, I just want those check boxes to be checked which have been returned by API. Means it like a ticketing system. For example i have array of seatdata and i want to checked those checkboxes which has id in php array. <?php $seatdata = array("A1", "A6", "A10","A11"); ?> <table> <tr> <td><input type='checkbox' name='seatdata[]' value='0|12' id="A11" /><label for="A11">A11</label></td> <td><input type='checkbox' name='seatdata[]' value='0|11' id="A10"/> <label for="A10">A10</label></td> <td><input type='checkbox' name='seatdata[]' value='0|10' id="A9" /><label for="A9">A9</label></td> <td><input type='checkbox' name='seatdata[]' value='0|9' id="A8" /><label for="A8">A8</label></td> <td><input type='checkbox' name='seatdata[]' value='0|6' id="A7" /><label for="A7">A7</label></td> <td><input type='checkbox' name='seatdata[]' value='0|5' id="A6" /><label for="A6">A6</label></td> <td><input type='checkbox' name='seatdata[]' value='0|4' id="A5" /><label for="A5">A5</label></td> <td><input type='checkbox' name='seatdata[]' value='0|3' id="A4" ?> /><label for="A4">A4</label></td> <td><input type='checkbox' name='seatdata[]' value='0|2' id="A3" /><label for="A3">A3</label></td> <td><input type='checkbox' name='seatdata[]' value='0|1' id="A2" /><label for="A2">A2</label></td> <td><input type='checkbox' name='seatdata[]' value='0|0' id="A1"/><label for="A1">A1</label></td> </tr>

Aucun commentaire:

Enregistrer un commentaire