【发布时间】:2015-03-04 04:39:26
【问题描述】:
我有一组复选框,当出现提交错误时,我需要保持它们处于选中状态。如果没有进行选择,它会验证并显示错误,但如果它回发,则不会保持选中的框。
HTML
<div class="fieldBox">
<div class="label"><p class="bold">Special Needs</p></div>
<div class="field"><?php echo $snMessage; ?>
<input type="checkbox" id="none" value="None" name="sNeeds[None]" <?php echo(in_array('None',$sNeeds))?'checked="checked"':'';?> /><label for="none"> <span></span>None</label>
<input type="checkbox" id="IEP" value="IEP" name="sNeeds[IEP]" <?php echo(in_array('IEP',$sNeeds))?'checked="checked"':'';?> /><label for="IEP"><span></span>IEP</label>
<input type="checkbox" id="405" value="405" name="sNeeds[405]" <?php echo(in_array('405',$sNeeds))?'checked="checked"':'';?> /><label for="405"><span></span>405</label>
</div>
</div>
PHP
$sNeeds = array('None', 'IEP', '405');
//Check Special Needs
if(empty($_POST['sNeeds'])) {
$snMessage .= '<p class="errorClass">Required</p>';
}
我哪里做错了?提前感谢您的宝贵时间!
【问题讨论】:
-
PHP 在外部 PHP 页面中