我可以显示来自SQL查询的复选框值,但我无法更新它们,我只能更新取消勾选值(0值),如果我取消选中复选框,它可以将取消勾选值0保存到SQL表中。如果我重新选中该复选框,则无法更新 SQL 查询中的值。我使用 int 作为数据类型。下面是来自我的测试系统的示例代码:
复选框:
<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>
复选框回声编辑功能:
<?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 if($value == 1){ ?>
$("#<?php echo $key ?>").attr("checked", true).prop("checked", true);
<?php } ?>
<?php
}
?>
$("#filter_id").val('<?php echo $rs_sql['id'] ?>');
$("#promotion_content").jqteVal('<?php echo $rs_sql['promotion_content'] ?>');
$("#promotion_terms").jqteVal('<?php echo $rs_sql['promotion_terms'] ?>');
$("#promotion_instruction").jqteVal('<?php echo $rs_sql['promotion_instruction'] ?>');
$("#promotion_policy").jqteVal('<?php echo $rs_sql['promotion_policy'] ?>');
<?php
}
?>
慕斯709654