•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 401,693 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,757 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 2457 | Replies: 2
![]() |
•
•
Join Date: Aug 2005
Posts: 10
Reputation:
Rep Power: 4
Solved Threads: 0
Hi,
I would like to check with you how JSP codes residing in js function works.
How can I get the 2nd select stmt executed based on the values retrieve from 1st select statement and the conditions pass in to this js function
How can I get the select statement to execute only when a condition is met.
The following is the codes. It is not executing the 2nd select statement. when I didnt put in the 2nd select stmt, i manage to execute codes in that portion
script
====
function test(obj, obj2) {
<%
sql_query = "SELECT a1, a2 , a3, a4, a5 "+
" FROM table_a ";
try {
rset = db.execSQL(sql_query);
}
catch(SQLException e){
System.err.println ("Error in query " +e);
}
%>
var po_ln_fnd = false
<% while (rset.next()) {
j_a1 = rset.getString("a1");
j_a2 = rset.getString("a2");
j_a3 = rset.getString("a3");
%>
if ((eval(obj2.value)== '<%=j_a1%>')) {
if ((obj.value == '<%=j_a2%>') ) {
<% j_a4 = rset.getString("a4");
j_a5 = rset.getString("a5");
sql_query = "SELECT b2, b3, b4 "+
" FROM table_b "+
" WHERE b1 = '"+j_a3+"' ";
try {
rset = db.execSQL(sql_query);
}
catch (SQLException e) {
System.err.println("Error in query " +e);
}
while (rset.next()) {
j_b2 = rset.getString("j_b2");
j_b3 = rset.getString("j_b3");
j_b4 = rset.getString("j_b4");
}
%>
}
}
<%}>
}
I would like to check with you how JSP codes residing in js function works.
How can I get the 2nd select stmt executed based on the values retrieve from 1st select statement and the conditions pass in to this js function
How can I get the select statement to execute only when a condition is met.
The following is the codes. It is not executing the 2nd select statement. when I didnt put in the 2nd select stmt, i manage to execute codes in that portion
script
====
function test(obj, obj2) {
<%
sql_query = "SELECT a1, a2 , a3, a4, a5 "+
" FROM table_a ";
try {
rset = db.execSQL(sql_query);
}
catch(SQLException e){
System.err.println ("Error in query " +e);
}
%>
var po_ln_fnd = false
<% while (rset.next()) {
j_a1 = rset.getString("a1");
j_a2 = rset.getString("a2");
j_a3 = rset.getString("a3");
%>
if ((eval(obj2.value)== '<%=j_a1%>')) {
if ((obj.value == '<%=j_a2%>') ) {
<% j_a4 = rset.getString("a4");
j_a5 = rset.getString("a5");
sql_query = "SELECT b2, b3, b4 "+
" FROM table_b "+
" WHERE b1 = '"+j_a3+"' ";
try {
rset = db.execSQL(sql_query);
}
catch (SQLException e) {
System.err.println("Error in query " +e);
}
while (rset.next()) {
j_b2 = rset.getString("j_b2");
j_b3 = rset.getString("j_b3");
j_b4 = rset.getString("j_b4");
}
%>
}
}
<%}>
}
•
•
Join Date: Aug 2005
Location: Socialist Republic of Boulder
Posts: 216
Reputation:
Rep Power: 4
Solved Threads: 6
•
•
•
•
Originally Posted by tllcll
sql_query = "SELECT b2, b3, b4 "+
" FROM table_b "+
" WHERE b1 = '"+j_a3+"' ";
...
while (rset.next()) {
j_b2 = rset.getString("j_b2");
j_b3 = rset.getString("j_b3");
j_b4 = rset.getString("j_b4");
Just an eyeball look here....
your calling tables b2, b3 and b4 in your select statement. Then you are requesting values j-b2, etc...
Might be the problem.
Regards,
Nate
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Login page. JSP/Servlet (JSP)
- execute jsp in tomcat (JSP)
- using jsp for a calendar connected to oracle (Oracle)
- source for LED using parallel port codes (Visual Basic 4 / 5 / 6)
- Problem connecting my Tomcat Server and MySQL using JSP (JSP)
- Passing result codes to a batch file (Python)
- Event not fired on reselection Frameset (ASP.NET)
Other Threads in the JSP Forum
- Previous Thread: somebody help me!
- Next Thread: Cross-browser script... Not working for Opera...


Linear Mode