CodeIgniter에서 체크 박스 값을 확인하는 데 문제가 있습니다. 여기에있는 해결책을 구현하려고합니다 : Codeigniter checking checkbox value. 체크 된 체크 박스에 관계없이 다음 코드는 절대로 true로 평가되지 않습니다. 입력에 value = "1"을 추가하면 항상 true가 평가됩니다.CodeIgniter 체크 박스 값 확인
내보기 :
....
<input name="Tuesday" id="Tuesday" type="checkbox" />
....
<script type="text/javascript">
.on('finished', function(e) {
var form_data = {
Tuesday: $('#Tuesday').val(),
ajax: '1'
};
$.ajax({
url: "<?php echo site_url('opportunity/create_opportunity'); ?>",
type: 'POST',
data: form_data,
dataType: 'json',
cache: false
});
})
</script>
내 컨트롤러 : 당신이 제공 할 수있는 어떤 도움
function create_opportunity() {
if($this->input->post('ajax')) {
$checked = $this->input->post('Tuesday');
if((int) $checked == 1) {
$Tuesday = array(
'Week_Day_Id' => 2,
'Opportunity_Id' => 18,
'Preferred' => $checked
);
}
$this->ion_auth_model->create_opportunity($Opportunity, $Tuesday);
}
}
감사합니다.
하세요'위해서 var_dump (체크 $)를'와 출력을 보여
나는 같은 것을 할 것입니다. – nightgaunt