I have a system where people fill in their information and later can go back and edit certain parts, basically the enter personal info and check whether they want to know extra info, these bits of extra infos are checkboxes, 3 of them. the user will select up to any of the 3 and the database has 3 fields , if they select one it changes to 1. I want them to be able to go back and deselect or reselect any of these 3 checkboxes, so what i want for the checkboxes to be selected if the values is 1.
I gather some kind of if statement but not sure how to involve it in a checkbox.
html
<div class="form-group col-lg-6">
<label class="control-label col-lg-4">Pricing<span style="color:red;"> </span></label>
<div class="col-lg-8">
<input type="checkbox" name="rm_option" id="rm_option" value="1"><strong> RM </strong></input>
<input type="checkbox" name="point_option" id="point_option" value="1"><strong> Full Point </strong></input>
<input type="checkbox" name="partial_option" id="partial_option" value="1"><strong> Partial Point + RM </strong></input>
</div>
</div>
show edit data function
html
<?php
$sql = "select * from promotion_list where id=" . $_GET['id'];
$arr_sql = db_conn_select($sql);
foreach ($arr_sql as $rs_sql) {
foreach ($rs_sql as $key => $value) {
?>
$("#<?php echo $key ?>").val("<?php echo $value?>");
<?php
}
?>
Now my problem is only checkbox unable show the tick in the checkbox, below is my output unable show the tick in the checkbox (red circle):
Anyone can guide me how to show the tick in the checkbox. I have tried to change checkbox input type to "text", it has data. And I have using this example method <?php if($rs_sql['rm_option']=== '1') echo 'checked="checked"';?> />
put into show edit data function, but still can't work. It just can show the value, unable show the tick in the checkbox.
Thanks a lot.
Aucun commentaire:
Enregistrer un commentaire