<%@ 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>
&#13;
在此代码中,无线电按钮功能不正常,所有的无线电按钮都会被检查。 以及如何在数据库中存储当前和不存在的值。 是否有任何其他特殊的动态表必须用于这些radiobuttons,或者我们可以使用这个普通表本身。
答案 0 :(得分:0)
所有的无线电按钮都经过检查
这是因为您的每个radio
按钮都有不同的name
属性