Share on Google+Share on Google+

john
JSP:NEED RESPONSE ASAP PLEASE!
2 Answer(s)      6 years and 11 months ago
Posted in : JSP-Servlet
Hi freind,

If you could respond to my previous thread which hasn't been addressed for over a week, I'd really appreciate it. and most important if you could just respond to below. thank you
I have a javascript that captures data from a highlighted row in a table and then sends this data in url to the next jsp page. The code works fine for a highlighted row that has one integer (id) column and a date column. However, i have another requirement similar where instead of the id I have to get a String a (name) column with a date. Im putting up the code, really appreciate if you can respond asap have a deadline in a day!!!! thanks


.c1 {background-color: #a6c4d4;}
.c2 {background-color: #a6c4d4;}
.c3 {background-color: #68C2EF;}


function ov(i){
document.getElementById(i).className="c3";
}
function ot(i,c){
document.getElementById(i).className=c;
}
function click(ide,d1,d2,d3){
var st=new String(d3);
if(st.length==1){
d3="0"+d3;
var d=d1+"-"+d2+"-"+d3;
alert("Editing Patient Data with ID: " +ide)
window.location.replace('http://localhost:8080/Medicare/visit_edit.jsp?id='+ide+'&&dd='+d,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes');
}
else{
var d=d1+"-"+d2+"-"+d3;
alert("Editing Patient Data with ID: " +ide)
window.location.replace('http://localhost:8080/Medicare/visit_edit.jsp?id='+ide+'&&dd='+d,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes');
}
}

Ads

View Answers

May 26, 2010 at 1:15 PM


Hi Friend,

Try the following code:

1)tablepopup.jsp:

<[email protected] 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>


May 26, 2010 at 1:16 PM


continue..

2)popup.jsp:

<[email protected] import="java.sql.*"%>
<%
String name=request.getParameter("name");
String dd=request.getParameter("dd");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
String query = "select * from client where name='"+name+"' and visitedDate='"+dd+"'";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);

String nn="",add="",contact="",ide="";
while(rs.next()){
nn=rs.getString("name");
add=rs.getString("address");
contact=rs.getString("contactNo");
ide=rs.getString("id");
}
response.sendRedirect("tablepopup.jsp?id="+ide+"&&name="+nn+"&&contactNo="+contact+"&&address="+add);


%>

Thanks









Related Tutorials/Questions & Answers:
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads