单选按钮无法正常工作


Radio buttons not working as they should

>我有两个代码。 当我提交表单时,它始终默认为选中的否

<td><input type="radio" onclick="selbustbl(1)" name="rdo2" id="busyes" value="yes" <? if(isset($_POST['rdo2']) == 'yes') echo " checked";  ?> />Yes</td>
<td><input type="radio" onclick="selbustbl(2)" name="rdo2" id="busno" value="no" <? if(isset($_POST['rdo2']) == 'no') echo "checked";  ?> />No</td>

请帮忙

isset() 返回 truefalse 。不是"是"或"否"。因此,您需要先检查它是否设置,然后再检查其值。

if(isset($_POST['rdo2']) == 'yes')

应该是

if(isset($_POST['rdo2']) && $_POST['rdo2'] == 'yes')