我正在用php codeigniter创建在线考试系统,我遇到了问题,当我检查了多个或一个答案并刷新页面时,检查的答案将不会显示。请任何人对此代码有解决方案。
<div class="checkbox checkbox-replace color-green">
<input type="checkbox" id="chk_multi" onclick="return cheked_data()"
name="<?php echo $question['question_bank_id'].'[]'; ?>"
class="check_v" value="<?php echo $i + 1;?>">
<label style="color: #373e4a; font-size: 15px;">
<?php echo $options[$i];?>
</label>
</div>
</div>
<div class="col-md-6" style="margin-bottom: 15px; padding-right: 500px";>
<label class="container_radio">
<div>
<label style="color: #373e4a; font-size: 15px;">
<?php echo get_phrase('true');?>
</label>
</div>
<input type="radio" id="radio_true" class="check_v" onclick="return
cheked_data()" name="<?php echo
$question['question_bank_id'].'[]'; ?>" value="<?php echo $this-
>session-
>userdata($arraydata['radio_true']);?>" >
<span class="checkmark"></span>
</label>
</div>
脚本类似于:
$(function checked_data() {
var chk_multi = $("input#chk_multi").val();
var chk_img = $("input#chk_image").val();
var radio_true = $("input#radio_true").val();
var radio_false = $("input#radio_false").val();
var fill_blank = $("input#fill_blank").val();
var data = { 'services[]' : []};
$("input:checked").each(function() {
data['services[]'].push($(this).val());
});
$.ajax({
type:'POST',
url:'<?php echo base_url();?>student/hold_checked/'+$online_exam_id,
data: {chk_multi: chk_multi,chk_img: chk_img,radio_true: radio_true,
radio_false: radio_false,fill_blank: fill_blank}
success: function(data){
$('#chk_multi').html(data);
$('#chk_image').html(data);
$('#radio_false').html(data);
$('#radio_true').html(data);
$('#fill_blank').html(data);
}
});
});
</script>
答案 0 :(得分:0)
您可以将复选框的值保存到localStorage中,我想您的问题与此相似[请检查下面的链接] localStorage how to save a checkbox