Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 ----

HTML
<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>


Check the images for more details (Google Drive Link)
IMAGE 1
IMAGE 2
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900