我试图在选择一个选项后立即禁用其他选项,但使用 java 脚本我无法做到这一点。请帮我。到目前为止我已经尝试过
<?php
$answer = $exm->getAnswer($number);
if ($answer) {
while ($result = $answer->fetch_assoc()) {
?>
<tr>
<td>
<input id="question_radio" type="radio" name="ans" value="<?php echo $result['id']; ?>"/><?php echo $result['ans']; ?>
<script id="question_radio" type="text/javascript">$(":radio").click(function(){
var radioName = $(this).attr("ans"); //Get radio name
$(":radio[name='"+radioName+"']:not(:checked)").attr("disabled", true); //Disable all unchecked radios with the same name
});
</script>
</td>
</tr>
<?php } } ?>
<tr>
<td>
<input type="submit" name="submit" value="Next Question"/>
<input type="hidden" name="number" value="<?php echo $number; ?>" />
</td>
</tr>
子衿沉夜
陪伴而非守候