简体   繁体   English

如何在数据库中存储单选按钮数据

[英]how to store radiobutton data in the database

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>HTML Tables</title> </head> <body> <%@ page import="java.sql.*"%> <table bgcolor="lightgray" border="5" width="60%" cellpadding="5" cellspacing="0.5" color="blue" > <tr> <th colspan ="3" bgcolor="#999999"><br> <div align="Center" > <font face="verdana" size="5" color="white"> ATTENDANCE </font> </div> </th> </tr> <tr> <td width="14%"><h3>Register No</td> <td><h3> Student Name</td> <td><h3> Attendance</td> </tr> <!-- <tr> <td> 1 </td> <td> Tom </td> <td> <input type="radio" name="rdbutton1">Present <input type="radio" name="rdbutton1">Absent <tr> <td>2</td> <td> Jerry </td> <td> <input type="radio" name="rdbutton2">Present <input type="radio" name="rdbutton2">Absent </tr>--> <% Connection dbcon=null; DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); dbcon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger"); Statement stmt=dbcon.createStatement(); ResultSet rst=null; rst=stmt.executeQuery("select regno, name from studentreg"); while(rst.next()) {%> <tr> <td><%=rst.getString("regno")%></td> <td><%=rst.getString("name")%></td> <!-- <td><%=1%></td> <td><%=rst.getString("name")%></td>--> <td> <input type="radio" name="rdbutton1">Present <input type="radio" name="rdbutton2">Absent </tr> <% } %> </table> </body> </html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> </body> </html> 

In this code the radiobuttons are not functions properly, all the radiobuttons are getting checked. 在此代码中,单选按钮无法正常工作,所有单选按钮均已检查。 And how to store the present and absent values in the database. 以及如何在数据库中存储当前值和缺失值。 Is there any other special dynamic tables that has to be used for these radiobuttons, or can we use with this normal table itself. 这些单选按钮是否有其他必须使用的特殊动态表,或者我们可以将此普通表本身使用。

all the radiobuttons are getting checked 所有单选按钮都已检查

that's because each of your radio button has a different name attribute 那是因为您的每个radio按钮都有不同的name属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM