简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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