请帮助我将所选动态创建的单选按钮的值显示到 div 中
这是我的代码...请告诉我我的代码出了什么问题...谢谢
<script type="text/javascript">
var div = $("#show_ans");
$("input[type='radio']").click(function() {
var radioVal = $(this).value;
div.html("radioVal");
});
</script>
html代码是
$i=0
$sql = mysql_query("SELECT * FROM `question_bank` where `test_name`='$tname'
AND`posted_by`='$fac'");
if (mysql_num_rows($sql) > 0)
while($row2 = mysql_fetch_array($sql))
{
if($i<=$maxq){
....
....
<table>
<tr><td colspan=3><?php echo $row2['question'];?></td>
<td><ul class="menu">
<li><div id="show_ans" style="display:none"></div>
</li></ul>
</td>
</tr>
<tr><td style="width:250px" align=left>
<input id="r1" type="radio" name="<?php echo "s_option".$i;?>" value="<?php echo $row2['choice_a'];?>" ><?php echo $row2['choice_a'];?>
</td>
<td style="width:250px" align=left>
<input id="r1" type="radio" name="<?php echo "s_option".$i;?>" value="<?php echo $row2['choice_b'];?>" ><?php echo $row2['choice_b'];?>
</td>
<td style="width:250px" align=left>
<input id="r1" type="radio" name="<?php echo "s_option".$i;?>" value="<?php echo $row2['choice_c'];?>" ><?php echo $row2['choice_c'];?>
</td>
<td style="width:250px" align=left>
<input id="r1" type="radio" name="<?php echo "s_option".$i;?>" value="<?php echo $row2['choice_d'];?>" ><?php echo $row2['choice_d'];?>
</td>
</tr>
</table>
....
....
如果单击单选按钮,则应在相应的 div 上生成值,并且应在所有循环重复中重复该值。请指导我提前谢谢。