load pull down menu on JSP page

J

jt

I am new to Javascript and I am having problems with loading a pull
down menu.

I get this error:
javax.servlet.ServletException: No data found

It will list the items just fine if I just list the items without
using the select & option tags. I would like to know why I am getting
an error with the following statement:

<select size="1" name="org">
<% while (rs.next()) { %>
<option value="<%=rs.getString("ORG_CODE")%>">
<%=rs.getString("ORG_CODE")%>
</option>
<% } %>
</select>

Thank you.
-jptu
 
M

Michael Winter

I am new to Javascript and I am having problems with loading a pull
down menu.
OK...

I get this error:
javax.servlet.ServletException: No data found

It will list the items just fine if I just list the items without
using the select & option tags. I would like to know why I am getting
an error with the following statement:

<select size="1" name="org">
<% while (rs.next()) { %>
<option value="<%=rs.getString("ORG_CODE")%>">
<%=rs.getString("ORG_CODE")%>
</option>
<% } %>
</select>

....but I don't see how this is related to JavaScript. You're problem is
with JSP.

You can find the JSP support forums at:

<URL:http://forum.java.sun.com/forum.jsp?forum=45>

Good luck,
Mike
 
K

kaeli

I am new to Javascript and I am having problems with loading a pull
down menu.

I get this error:
javax.servlet.ServletException: No data found

Probably because your query isn't returning any data, but something
expects it to.

It will list the items just fine if I just list the items without
using the select & option tags. I would like to know why I am getting
an error with the following statement:

<select size="1" name="org">
<% while (rs.next()) { %>
<option value="<%=rs.getString("ORG_CODE")%>">
<%=rs.getString("ORG_CODE")%>
</option>
<% } %>
</select>

You have no code here as to what to do if there is no rs.next() - that
is, if the query returns no rows. If it returns no rows, you get an
empty select element. That might be mucking up other code that assumes
there is data in the select element.
Add code that counts how many rows are returned, then check that and
throw an error or something to handle 0 rows.


--
 
P

phuong tu

Thanks for all your inputs. Sorry, I should have posted this under
java. I found 2 tips to make it work.

1. I changed my select statement from "select * ..." to "select ORG_CODE
..."
2. I assigned the data pulled from recordset to a variable before
inserting it to the pull down.

here's the revised version:
<select size="1" name="org">
<%
String org = null;
while (rs.next())
{
org = rs.getString("ORG_CODE"); %>
<option value="<%=org%>">
<%=org%>
</option>
<%
} %>
</select>
 
K

kaeli

Thanks for all your inputs. Sorry, I should have posted this under
java. I found 2 tips to make it work.

1. I changed my select statement from "select * ..." to "select ORG_CODE
.."
2. I assigned the data pulled from recordset to a variable before
inserting it to the pull down.

You might also want to do something special in case the org code is
null, if null values are allowed. Otherwise it just prints out the
string "null", which might not be what you want.


--
--
~kaeli~
The more ridiculous a belief system, the higher probability
of its success.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top