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 know the selected row from table - JSP-Interview Questions
Advertisements
how to display the selected row from the data table in model panel ??
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 insert the selected item of combobox in mysql - XML
how to get data using dropdownlist, textbox and search button in jsp
how to by default chceckbox button is selected in struts
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database - Java Beginners
Maintaining States of Selected CheckBoxes in Different Pages using dispaly table in struts2
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
How to Extract row from table view using JSP Code - Java Beginners
JavaScript add row to table
how to display selected checkboxes dynamically using jsp
delete row from a table using hibernate
JSP1
JSP2
Delete and add row from Table View iPhone
jsp :how to edit table of data displayed using jsp when clicked on edit button
Java JComboBox Get Selected Item Value
getting radio button at start of each row of table - Struts
navigation item back button
How to perform search using AJAX?
jsp :how to edit table of data displayed using jsp when clicked on edit button
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
nested selected tag ihave display selected item
How to add dropdown list in a row of a sort table applet?
How to get table row contents into next jsp page
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?

Ads