How to search the selected item in row table using radia button in JSP?

Ads
 

How to search the selected item in row table using radia button in JSP?

How to search the selected item in row table using radia button in JSP?

View Answers

April 5, 2011 at 4:39 PM

1)radioselection.jsp:

<%@ page import="java.sql.*" %>
<html>
<form name="form"  method="post" action="search.jsp">
 <table border="1">
<tr><th></th><th>Name</th></tr>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
String query = "select * from employee";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><input type="radio" value="<%= rs.getString("id")%>"   name="radio">
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
<input type="submit" value="Search">
</form>
</html>

2)search.jsp:

<%@ page import="java.sql.*" %>
<form>
<table border=1>
<%
String value=request.getParameter("radio");
int v=Integer.parseInt(value);
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=conn.createStatement();
ResultSet rs = st.executeQuery("select * from employee where id="+v+"");
if(rs.next()){ 
    %>
<tr><td>Name: </td><td<input type="text" value="<%=rs.getString("name")%>" > </td></tr>
<tr><td>Address: </td><td<input type="text" value="<%=rs.getString("address")%>" > </td></tr>
<tr><td>Contact No: </td><td<input type="text" value="<%=rs.getInt("contactNo")%>" > </td></tr>
<tr><td>Email: </td><td<input type="text" value="<%=rs.getString("email")%>" > </td></tr>
      <%
}
%>
</table>
</form>

Ads









Related Tutorials/Questions & Answers:
How to search the selected item in row table using radia button in JSP?
how to display the selected row from the data table in model panel ??
Advertisements
How to identify the radio button id and row id in a table in jsp?
Adding button to each row for the table and adding row to another table
how to get data using dropdownlist, textbox and search button in jsp
how to by default chceckbox button is selected in struts
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax
Maintaining States of Selected CheckBoxes in Different Pages using dispaly table in struts2
how to display selected checkboxes dynamically using jsp
JavaScript add row to table
jsp :how to edit table of data displayed using jsp when clicked on edit button
delete row from a table using hibernate
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
jsp :how to edit table of data displayed using jsp when clicked on edit button
How to perform search using AJAX?
Java JComboBox Get Selected Item Value
How to get table row contents into next jsp page
How to delete the row from the Database by using servlet
How to add dropdown list in a row of a sort table applet?
navigation item back button
JSP1
JSP2
nested selected tag ihave display selected item
how to write a program to search a record using mvc2
Deleting a Row from SQL Table Using EJB
how to generate automatic bill based on selected values using jsp/javascript?
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?
how to delete a row in sql without using delete command.
How to change table row color when click on Hyper Link in jsp?
delete row from a table in hibernate

Ads