我写了下面的代码,它工作得很好并且达到了它的目的,但是我有两个问题。1.它允许选择多个答案& 2.没有选择答案时没有错误消息。
<div id="p1" class="SlidingPanelsContent">
<div class="question">
<div class="label"><span class="number"><?=$question_id++; ?>.</span>
<? echo $question; ?>
</div>
<div class="answer" onmouseover="javascript:changeBgColor(event, '#B900A5');" onmouseout="javascript:restoreBgColor(event);" onclick="this.checked=true; ">
<input tabindex="-1" type="radio" name="<?php echo rand(); ?>" value="<?=$ans1; ?>" ><? echo $ans1; ?></div>
<div class="answer" onmouseover="javascript:changeBgColor(event, '#B900A5');" onmouseout="javascript:restoreBgColor(event);" onclick="this.checked=true;">
<input tabindex="-1" type="radio" name="<?php echo rand(); ?>" value="<?=$ans2; ?>" ><?=$ans2; ?></div>
<div class="answer" onmouseover="javascript:changeBgColor(event, '#B900A5');" onmouseout="javascript:restoreBgColor(event);" onclick="this.checked=true;">
<input tabindex="-1" type="radio" name="<?php echo rand(); ?>" value="<?=$ans3; ?>" ><?=$ans3; ?></div>
<div class="answer" onmouseover="javascript:changeBgColor(event, '#B900A5');" onmouseout="javascript:restoreBgColor(event);" onclick="this.checked=true;">
<input tabindex="-1" type="radio" name="<?php echo rand(); ?>" value="<?=$ans4; ?>" ><?=$ans4; ?></div>
</div>
</div>