Php 保持不活动复选框在表单提交后禁用或不活动—;验证或重新填充时间
我将引导与PHP Codeigniter一起使用。我的表格中有几个复选框。如果我单击一个复选框,其他一些复选框将被禁用,颜色为灰色。但在验证时提交表单后,那些禁用或不活动的复选框变为活动状态并失去灰色。但我不希望这种行为 HTML部分:Php 保持不活动复选框在表单提交后禁用或不活动—;验证或重新填充时间,php,twitter-bootstrap,codeigniter,checkbox,Php,Twitter Bootstrap,Codeigniter,Checkbox,我将引导与PHP Codeigniter一起使用。我的表格中有几个复选框。如果我单击一个复选框,其他一些复选框将被禁用,颜色为灰色。但在验证时提交表单后,那些禁用或不活动的复选框变为活动状态并失去灰色。但我不希望这种行为 HTML部分: <div class="align"> <label> <input type="checkbox" size="2" name="M1500" v
<div class="align">
<label> <input type="checkbox" size="2" name="M1500" value="01" <?php echo set_checkbox('M1500', '01' ); ?> class="chec1_1500 checker1510"> No </label>
<label> <input type="checkbox" size="2" name="M1500" value="02" <?php echo set_checkbox('M1500', '02' ); ?> class="chec1_1500 " > Yes</label>
<label> <input type="checkbox" size="2" name="M1500" value="03" <?php echo set_checkbox('M1500', '03' ); ?> class="chec1_1500 checker1510" > Not assessed</label>
<label> <input type="checkbox" size="2" name="M1500" value="NA" <?php echo set_checkbox('M1500', 'NA' ); ?> class="chec1_1500 checker1510" > Patient does not have diagnosis of heart failure</label>
</div>
<div class="align">
<label> <input type="checkbox" name="M1510_1" class="check_1510" Size="1" <?php echo set_checkbox('M1510_1', '1' ); ?> value="1" onclick="SetAllCheckBoxes('myForm', 'myCheckbox1',this.checked);" style="padding-right:20px;" value="1" > No action taken</label>
<label> <input type="checkbox" name="M1510_2" class="check_1510" Size="1" <?php echo set_checkbox('M1510_2', '2' ); ?> id="myCheckbox1" value="2" > Patient’s Physician</label>
<label> <input type="checkbox" name="M1510_3" class="check_1510" Size="1" <?php echo set_checkbox('M1510_3', '3' ); ?> id="myCheckbox1" value="3" > Patient </label>
<label> <input type="checkbox" name="M1510_4" class="check_1510" Size="1" <?php echo set_checkbox('M1510_4', '6' ); ?> id="myCheckbox1" value="6" > Obtained </label>
</div>
$('input.chec1_1500').on('change', function() { // 1 checked others disable in same
$('input.chec1_1500').not(this).prop('disabled', this.checked);
$('input.chec1_1500').not(this).prop('checked', false);
});
$('.checker1510').change(function() { // To disable 1510
$('input.check_1510').not(this).prop('checked', false);
$('.check_1510').not(this).prop('disabled', this.checked);
});
public function transfer_add(){
sleep(1);
$data=array();
$this->form_validation->set_rules('M1500','','callback_check_1500');
$this->form_validation->set_rules('M1510_1','','');
$this->form_validation->set_rules('M1510_2','','');
$this->form_validation->set_rules('M1510_3','','');
$this->form_validation->set_rules('M1510_4','','');
if($this->form_validation->run()==FALSE){
$this->load->view('transfer');
} else {
$data['M1500 '] =$this->input->post('M1500');
$data['M1510_1'] =$this->input->post('M1510_1');
$data['M1510_2'] =$this->input->post('M1510_2');
$data['M1510_3'] =$this->input->post('M1510_3');
$data['M1510_4'] =$this->input->post('M1510_4');
$this->groups_model->add_transfer($data);
redirect('transfer/index');
}
}
控制器:
<div class="align">
<label> <input type="checkbox" size="2" name="M1500" value="01" <?php echo set_checkbox('M1500', '01' ); ?> class="chec1_1500 checker1510"> No </label>
<label> <input type="checkbox" size="2" name="M1500" value="02" <?php echo set_checkbox('M1500', '02' ); ?> class="chec1_1500 " > Yes</label>
<label> <input type="checkbox" size="2" name="M1500" value="03" <?php echo set_checkbox('M1500', '03' ); ?> class="chec1_1500 checker1510" > Not assessed</label>
<label> <input type="checkbox" size="2" name="M1500" value="NA" <?php echo set_checkbox('M1500', 'NA' ); ?> class="chec1_1500 checker1510" > Patient does not have diagnosis of heart failure</label>
</div>
<div class="align">
<label> <input type="checkbox" name="M1510_1" class="check_1510" Size="1" <?php echo set_checkbox('M1510_1', '1' ); ?> value="1" onclick="SetAllCheckBoxes('myForm', 'myCheckbox1',this.checked);" style="padding-right:20px;" value="1" > No action taken</label>
<label> <input type="checkbox" name="M1510_2" class="check_1510" Size="1" <?php echo set_checkbox('M1510_2', '2' ); ?> id="myCheckbox1" value="2" > Patient’s Physician</label>
<label> <input type="checkbox" name="M1510_3" class="check_1510" Size="1" <?php echo set_checkbox('M1510_3', '3' ); ?> id="myCheckbox1" value="3" > Patient </label>
<label> <input type="checkbox" name="M1510_4" class="check_1510" Size="1" <?php echo set_checkbox('M1510_4', '6' ); ?> id="myCheckbox1" value="6" > Obtained </label>
</div>
$('input.chec1_1500').on('change', function() { // 1 checked others disable in same
$('input.chec1_1500').not(this).prop('disabled', this.checked);
$('input.chec1_1500').not(this).prop('checked', false);
});
$('.checker1510').change(function() { // To disable 1510
$('input.check_1510').not(this).prop('checked', false);
$('.check_1510').not(this).prop('disabled', this.checked);
});
public function transfer_add(){
sleep(1);
$data=array();
$this->form_validation->set_rules('M1500','','callback_check_1500');
$this->form_validation->set_rules('M1510_1','','');
$this->form_validation->set_rules('M1510_2','','');
$this->form_validation->set_rules('M1510_3','','');
$this->form_validation->set_rules('M1510_4','','');
if($this->form_validation->run()==FALSE){
$this->load->view('transfer');
} else {
$data['M1500 '] =$this->input->post('M1500');
$data['M1510_1'] =$this->input->post('M1510_1');
$data['M1510_2'] =$this->input->post('M1510_2');
$data['M1510_3'] =$this->input->post('M1510_3');
$data['M1510_4'] =$this->input->post('M1510_4');
$this->groups_model->add_transfer($data);
redirect('transfer/index');
}
}
欢迎来到SO!如果您能提供一些代码,人们将更容易重新构建您的问题。在Codeigniter Form Validaiton,我正在使用@user3605897帮助您,我们需要您的视图(仅复选框部分)和控制器(表单验证部分),可能还需要您的setAllCheckBox()函数。请使用问题下方的编辑按钮。谢谢您的希望。这是我在这个网站上的第一篇帖子,任何错误请不要介意。我按你说的加了所有的。如果您需要更多,请告诉我如何发送给您。期待您的答复。阿德里安,再一次,谢谢你的希望,我会在等你的。。。。。。。!!