【发布时间】:2013-06-29 13:04:48
【问题描述】:
$facility=$_POST['interests'];
<input type="checkbox" name="interests[]" id="" value="wifi" value="<?php echo in_array('wifi', $facility)??>checked='checked'<?php:;?>" /><label class="check_label">Wifi</label>
<input type="checkbox" name="interests[]" id="" value="spa" value="<?php echo in_array('spa', $facility)?>checked='checked'<?php:;?>"/><label class="check_label">Spa</label>
<input type="checkbox" name="interests[]" id="" value="pet allowed" value="<?php echo in_array('pet allowed', $facility)?>checked='checked'<?php:;?>"/><label class="check_label">Pet Allowed</label>
第二种方法:-
<input type="checkbox" name="interests[]" id="" value="wifi" value="<?php in_array('wifi', $facility){?>checked='checked'<?php}?>" /><label class="check_label">Wifi</label>
<input type="checkbox" name="interests[]" id="" value="spa" value="<?php in_array('spa', $facility){?>checked='checked'<?php}?>"/><label class="check_label">Spa</label>
<input type="checkbox" name="interests[]" id="" value="pet allowed" value="<?php in_array('pet allowed', $facility){?>checked='checked'<?php}?>"/><label class="check_label">Pet Allowed</label>
如果用户犯了任何错误,我会同时应用这两种方法,以便在表单中保留帖子值。如果他犯了错误,复选框在提交后仍然选中,但它不起作用。
【问题讨论】:
-
很抱歉我在解决这个问题时很沮丧,但在原始脚本中是正确的