单选按钮在jsp页面中无法正常工作? [英] Radio Button not working correctly in jsp page ?
本文介绍了单选按钮在jsp页面中无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是,当页面加载并且我点击radiobutton时,只有第一个工作休息不起作用。意思是当我点击第一个单选按钮时,它显示我的id&名字,但当我点击其余没有任何作品,请帮助我。
这是我的代码----
My problem is that when the page is loaded and i click on the radiobutton only the first one work rest doesn't work. Means when i click the first radio button it shows me the id & name but when i click the rest nothing works, please help me.
THIS IS MY CODE ----
<body>
<%
try{
Connection con=null;
Class.forName("org.sqlite.JDBC");
con=DriverManager.getConnection("jdbc:sqlite:C:\\");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("Select id,name from tb1 group by id");
// Statement stmt2=con.createStatement();
// ResultSet rs2=stmt2.executeQuery("Select id,name from tb1");
%>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#view').click(function(){
var id=$(this).closest('tr').find('td:eq(0)').text();
var name=$(this).closest('tr').find('td:eq(1)').text();
alert(id+" "+name);
//$('#vv').slideToggle();
});
});
</script>
<form action="" method="">
<table id="tb1" style="text-align: center;border: solid black medium">
<tr>
<th>ID</th>
<th>NAME</th>
<th>View Data</th>
</tr>
<% while(rs.next()){%>
<tr>
<td><%= rs.getString(1) %></td>
<td><%= rs.getString(2) %></td>
<td><input type="radio" name="view" id="view" onclick="" /></td>
</tr>
<%}%>
</table>
</form>
查看图片了解更多详情(Google Drive Link)
IMAGE 1
IMAGE 2
推荐答案
( document )。ready ( function (){
(document).ready(function(){
(' #view')。click( function (){
var id =
('#view').click(function(){ var id=
( this )。nearest(' tr')。find(' td:eq(0)')。text();
var name =
(this).closest('tr').find('td:eq(0)').text(); var name=
这篇关于单选按钮在jsp页面中无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文