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?

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>









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
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 by default chceckbox button is selected in struts
delete row from a table using hibernate
How to Extract row from table view using JSP Code - Java Beginners
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database - Java Beginners
JavaScript add row to table
how to display selected checkboxes dynamically using jsp
JSP1
JSP2
getting radio button at start of each row of table - Struts
jsp :how to edit table of data displayed using jsp when clicked on edit button
Java JComboBox Get Selected Item Value
navigation item back button
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 get table row contents into next jsp page
Deleting a Row from SQL Table Using EJB
How to add dropdown list in a row of a sort table applet?
How to perform search using AJAX?
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?
How to delete the row from the Database by using servlet
delete row from a table in hibernate
How to change table row color when click on Hyper Link in jsp?
ModuleNotFoundError: No module named 'jspp'
ModuleNotFoundError: No module named 'JSPy'
how to generate automatic bill based on selected values using jsp/javascript?
how to write a program to search a record using mvc2
delete multiple row using checkbox
delete multiple row using checkbox
Hoe to refresh a table row dynamically
how to delete a row in sql without using delete command.
add image in a row of table
add image in a row of table
Highlight a corresponding table row - Struts
how to show search results in the same panel of jframe to where search field and button is present..
JavaScript add row dynamically to table
how to create own tld and use it in jspx file
how to create own tld and use it in jspx file
Insert specific fields into table dynamically for each row.

Ads