简体   繁体   English

复选框未检查时未返回值PHP Codeigniter

[英]Checkbox not returning value when not checked PHP Codeigniter

I have multiple checkboxes in the sampe page that have different values when checked or not. 我在样本页面中有多个复选框,无论是否选中,它们的值都不同。 And these checkboxes also read values from database. 这些复选框也从数据库读取值。 Here's some sample of my current code. 这是我当前代码的一些示例。

1. this one should returning 'Absent' if not checked 1.如果未选中,此文件应返回“缺席”

<label class="checkbox-inline" for="Chronic_skin">
    <?php echo form_checkbox('Chronic_skin', 'Present', $values->Chronic_skin ? 'checked' : null, 'id ="Chronic_skin"')?> <b>Chronic Skin Rash</b>
</label>

2. This one should returning 'Abnormal' if not checked 2.如果未选中此选项,则应返回“异常”

<label class="checkbox-inline" for="breath_sounds">
    <?php echo form_checkbox('breath_sounds', 'Normal', $values->breath_sounds? 'checked' : null, 'id ="breath_sounds"')?> <b>Breath Sounds</b>
</label>

3. And this one should returning 'No' if not checked 3.如果未选中,此选项应返回“否”

<label class="checkbox-inline" for="others">
    <?php echo form_checkbox('others', 'Yes', $values->others? 'checked' : null, 'id ="others"')?> <b>others</b>
</label>

The problem that I'm having now when i press submit button (post button) the unchecked checkboxes didnt return any value (I checked using print_r() command), but the checked checkboxes is showing the values. 我现在遇到的问题是,当我按下“提交”按钮(“发布”按钮)时,未选中的复选框没有返回任何值(我使用print_r()命令进行了检查),但是选中的复选框显示了这些值。 Any help will be very much appreciated. 任何帮助将不胜感激。 Thanks 谢谢

That's a common behavior. 这是常见的行为。 You can either check with some list of checkboxes, either the checkbox was sent out to the user or not, or you can accompany each checkbox with hidden input 您可以选中复选框的某些列表,或者将复选框发送或不发送给用户,或者可以将每个复选框与隐藏的输入一起显示

<?php echo form_hidden('others_checkbox', '1'); ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM