gridview中的单选按钮

时间:2015-10-22 17:58:42

标签: html css jsp

在此表中,当我检查第1行的单选按钮(当前)时,当我再次检查第2行的当前内容时,第1行会自动取消选中。所有的无线电按钮都会被检查。这只是两个学生的样本。

<%@ 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> <input type="radio" >Present <input type="radio">Absent
<tr>
<td>2</td>
<td> <input type="radio" >Present <input type="radio">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 * from studenttables");
while(rst.next())
{%> 
<tr>

<td><%=rst.getString("name")%></td>

</tr>
<tr>
<td><%=rst.getString("name")%></td>
</tr>

<tr>
<td><%=1%></td>
<td><%=rst.getString("name")%></td>
<td><input type="radio" >Present <input type="radio">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>

radiobutton gridview image

1 个答案:

答案 0 :(得分:2)

设置名称并制作一组单选按钮,如

<div class='controls'>
  <input id='content' type='textbox' value='CSS SHAPES, SVG, CANVAS DESIGNS ROCK' />
  <select id='fontsize'>
    <option value='10'>10px</option>
    <option value='12'>12px</option>
    <option value='14'>14px</option>
    <option value='16' selected>16px</option>
  </select>
  <select id='fontname'>
    <option value='Arial' selected>Arial</option>
    <option value='Verdana'>Verdana</option>
    <option value='Courier'>Courier</option>
  </select>
  <button id='draw'>Draw</button>
</div>
<canvas id='canvas'></canvas>

() - name="rdg1" and id="Present"
() - name="rdg1" and id="Absent"

如果检查了rdg1 - Present并单击以检查rdg1 - 缺少复选框1将清除,与第二组相同。