日期:2014-05-18  浏览次数:20732 次

诚恳贴 请大家帮下,想做成动态的一组单选框(每道题中的的4个选项内容从数据库中读取)
想做成动态的一组单选框(每道题中的4个选项内容从数据库中读取),然后让用户选择,想得到每到题用户的选项,可是程序出来后,每道题的单选项居然可以多选,希望得到CSDN高手们的帮助,十分感谢。

JSP代码如下:
<%@   page   contentType= "text/html;   charset=GB2312 "   %>
<%@   page   import= "java.sql.* "   %>
<html>
<head> <title> JDBC建立数据库连接 </title>
</head>
<body> <center>
<font   size   =   5   color   =   blue>   在线测试 </font> <hr>  
<%
    //加载驱动程序
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");  
    //建立连接数据库为:Test
    Connection   conn=DriverManager.getConnection( "jdbc:odbc:test ", " ", " ");  
    //发送SQL语句
    Statement   stmt=conn.createStatement();  
    try{
    //建立ResultSet(结果集)对象
    ResultSet   rs;  
    //执行SQL语句
    rs=stmt.executeQuery( "SELECT   *   FROM   singlechoose     ");  
%>
<table   border=3>
   
<%
        //利用while循环将数据表中的记录列出
    while   (rs.next()){
%>
    <tr>
          <td> id: <font   size=1> <%=   rs.getString( "id ")   %> </font> </td>
          <td> <font   size=1> <%=   rs.getString( "timu ")   %> </font> </td>
         
 
  <td> <input   type=radio   name= "a "   value= "a "   >
  <font   size=1> <%=   rs.getString( "a ")   %> </font> </td>
          <td>     <input   type=radio   name= "a "   value= "b "   >
  <font   size=1> <%=   rs.getString( "b ")   %> </font> </td>
         
  <td>   <input   type=radio   name= "c "   value= "c "   >
  <font   size=1> <%=   rs.getString( "c ")   %> </font> </td>
           
  <td>   <input   type=radio   name= " "   value= "d "   >
  <font   size=1> <%=   rs.getString( "d ")   %> </font> </td>
         
 
 
    </tr> </font>
<%
    }
    rs.close();   //关闭ResultSet对象
    }
    catch(Exception   e){
    out.println(e.getMessage());
    }
    stmt.close();   //关闭Statement对象
    conn.close();     //关闭Connection对象
%>
</table> </center>
</body> </html>

------解决方案--------------------
你的radio的name不是一样的,所以能够多选
------解决方案--------------------