Hi Friend,
Try the following code:
1)tablepopup.jsp:
<%@page import="java.sql.*"%>
<%
String id=request.getParameter("id");
String n=request.getParameter("name");
String address=request.getParameter("address");
String contact=request.getParameter("contactNo");
if((id!=null)&&(n!=null)&&(address!=null)&&(contact!=null)){
%>
<form action="edits.jsp">
<table border="1" >
<tr><td>Name:</td><td><input type="text" name="name" value="<%=n%>"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address" value="<%=address%>"></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contactNo" value="<%=contact%>"></td></tr>
<tr><td></td><td><input type=submit name="edit" value="Edit"></td></tr>
</table>
<input type="hidden" name="id" value="<%=id%>">
</form>
<%
}
else{
%>
<form action="adds.jsp">
<table border="1">
<tr><td>Name:</td><td><input type="text" name="name" value=""></td></tr>
<tr><td>Address:</td><td><input type="text" name="address" value=""></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contactNo" value=""></td></tr>
<tr><td></td><td><input type=submit name="button" value="Add"></td></tr>
</table>
</form>
<%}
%>
<style>
.c1 {background-color: white;}
.c2 {background-color: white;}
.c3 {background-color: red;}
</style>
<script>
function ov(i){
document.getElementById(i).className="c3";
}
function ot(i,c){
document.getElementById(i).className=c;
}
function click(i){
var x = document.getElementById('table');
var row = x.rows[i];
var cell1 = row.cells[0];
var content1 = cell1.firstChild.nodeValue;
var cell2 = row.cells[3];
var content2 = cell2.firstChild.nodeValue;
window.location.replace('
http://localhost:8080/examples/jsp/popup.jsp?name='+content1+'&&dd='+content2,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes');
}
</script>
</head>
<form>
Search:<input type="text" name="customer"><input type=submit value="Search">
</form>
<%
//String id=request.getParameter("id");
String name=request.getParameter("customer");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:
mysql://localhost:3306/register","root","root";);
Statement st = con.createStatement();
ResultSet rs=st.executeQuery("select * from client where name='"+name+"'");
%>
<form name="form">
<table id="table" border="1">
<%
int i=0;
while(rs.next()){
String d=rs.getString("visitedDate");
String sub1=d.substring(0,4);
String sub2=d.substring(5,7);
String sub3=d.substring(8,10);
System.out.println(sub1+" "+sub2+" "+sub3);
%>
<tr id=<%=rs.getString("id")%> class=c1 onclick='click(<%=i%>)' onmouseover='ov("<%=rs.getString("id")%>")' onmouseout='ot("<%=rs.getString("id")%>","c1")'><td><%=rs.getString("name")%></td><td ><%=rs.getString("address")%></td><td ><%=rs.getString("contactNo")%></td><td ><%=rs.getString("visitedDate")%></td></tr>
<%
i++;
}%>
</table>
</form>
</html>