【发布时间】:2014-01-17 16:00:20
【问题描述】:
我有
<input type="radio" value="1" name="is_active_<?php echo $v['class_id'] ?>" id="is_active_<?php echo $v['class_id'] ?>" <?php if($v['display_online']==1){ echo ' checked'; }?> >
<label for="is_active_no_<?php echo $v['display_online'] ?>">Yes </label>
<input type="radio" value="0" <?php if($v['display_online']==0){ echo 'checked'; }?> name="is_active_<?php echo $v['class_id'] ?>" id="is_active_<?php echo $v['class_id'] ?>">
<label for="active_yes_<?php echo $v['display_online'] ?>"> No </label>
在 for 循环中。 见图片:- 查看 html 输出:-
<input type="radio" id="is_active_47568" name="is_active_47568" checked="checked" value="1">
<label for="is_active_no_1">Yes </label>
<input type="radio" id="is_active_47568" name="is_active_47568" value="0">
<label for="active_yes_1"> No </label>
但是检查不工作是什么问题?
提前致谢。
【问题讨论】:
-
试试
echo checked='checked'; -
你好@AlirezaFallah 我试过这个,但也没有用。
-
粘贴此代码生成的 HTML 输出
-
可能你
if的结果是假的! -
可能 if($v['display_online']==0) 不正确,因此没有得到检查。检查 phhp 变量的值。
标签: php html radio-button