<div class="control-group">
<label class="control-label">Notification Views</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="1" <?php if(isset($POST ['n_index'])){ echo "checked!";}?> class="a1" title="Choose"> Teachers
</label>
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="2" <?php if(isset($POST ['n_index'])){ echo "checked!";}?> class="a1" title="Choose"> Parents
</label>
<br>
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="3" <?php if(isset($POST ['n_index'])){ echo "checked!";}?> class="a1" title="Choose"> Management
</label>
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="4" <?php if(isset($POST ['n_index'])){ echo "checked!";}?> class="a1" title="Choose"> Office
</label>
<?php echo form_error('n_index'); ?>
</div>
它是代码,复选框没有获取值。表格提交正在进行,方法发布。 请帮助一些。
答案 0 :(得分:1)
用$ _POST替换$ POST。
实施例
<?php if(isset($_POST['n_index'])){ echo "checked!";}?>
答案 1 :(得分:1)
试试这个
<div class="control-group">
<label class="control-label">Notification Views</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="1" <?php if(isset($_POST ['n_index']) && in_array('1', $_POST ['n_index'])){ echo 'checked="checked"';}?> class="a1" title="Choose"> Teachers
</label>
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="2" <?php if(isset($_POST ['n_index']) && in_array('2', $_POST ['n_index'])){ echo 'checked="checked"';}?> class="a1" title="Choose"> Parents
</label>
<br>
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="3" <?php if(isset($_POST ['n_index']) && in_array('3', $_POST ['n_index'])){ echo 'checked="checked"';}?> class="a1" title="Choose"> Management
</label>
<label class="checkbox">
<input type="checkbox" name="n_index[]" value="4" <?php if(isset($_POST ['n_index']) && in_array('4', $_POST ['n_index'])){ echo 'checked="checked"';}?> class="a1" title="Choose"> Office
</label>
<?php echo form_error('n_index'); ?>
</div>