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
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 get data using dropdownlist, textbox and search button in jsp
Maintaining States of Selected CheckBoxes in Different Pages using dispaly table in struts2
delete row from a table using hibernate
how to by default chceckbox button is selected in struts
JavaScript add row to table
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
JSP1
JSP2
how to display selected checkboxes dynamically using jsp
getting radio button at start of each row of table - Struts
Java JComboBox Get Selected Item Value
navigation item back button
Delete and add row from Table View iPhone
nested selected tag ihave display selected item
jsp :how to edit table of data displayed using jsp when clicked on edit button
Deleting a Row from SQL Table Using EJB
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
How to get table row contents into next jsp page
How to add dropdown list in a row of a sort table applet?
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
How to perform search using AJAX?
delete row from a table in hibernate
ModuleNotFoundError: No module named 'jspp'
ModuleNotFoundError: No module named 'JSPy'
how to generate automatic bill based on selected values using jsp/javascript?
delete multiple row using checkbox
delete multiple row using checkbox
How to change table row color when click on Hyper Link in jsp?
add image in a row of table
add image in a row of table
Highlight a corresponding table row - Struts
Hoe to refresh a table row dynamically
how to delete a row in sql without using delete command.
JavaScript add row dynamically to table
Deleting a Row from SQL Table Using EJB
Insert specific fields into table dynamically for each row.
how to create own tld and use it in jspx file
how to create own tld and use it in jspx file

Ads