如何在JSP单独文件中从数据库动态设置单选按钮值 [英] How to set radio button value from database(dynamically) in jsp separate file

查看:378
本文介绍了如何在JSP单独文件中从数据库动态设置单选按钮值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何设置数据库plz中单选按钮的值对我有帮助.

How i set the value of radio button from database plz help me..

try
        {
            
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection con=DriverManager.getConnection("jdbc:odbc:Test");
            Statement st=con.createStatement();
            ResultSet rs=st.executeQuery("select * from Online_Exam");
            while(rs.next())
            {             
               String s = rs.getString("choice1");
               
                out.println("<h4>" + rs.getString("questions") + "</h4>");
                /*out.print("<input type=radio name=i>");*/
               <big> out.print("<h5> <input type=\"radio\" name=\"a\" value=\""
                         + s + "\">");</h5></big>
               
                out.println("</body>");
                out.println("</html>");                     
            }
            con.close();
        }
        catch(Exception e)
            {
            
            }

推荐答案

在打印时将checked=true添加到要检查的收音机中.
Add a checked=true to the radio you want checked when you print it out.


这篇关于如何在JSP单独文件中从数据库动态设置单选按钮值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆