File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

listbox

 
maria pasha
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone.

i am retrieving records from one database in a listbox and have to insert the value selected into another database..

but i cannot seem to get the right syntax for getting the value selected. do i have to use an array?

and is it possible to do all of this embedding java snippits in the code? i have some constraints....i cannot make separate code for that?

please help
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is your existing code, please paste your code here ?

Shailesh
 
maria pasha
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.....

<%
ResultSet recresult = st1.executeQuery("Select * from CHART");

%>
<td>
<select name="id">
<%while(recresult.next()){%>

<option value=<%=recresult.getString(1)%>><%=recresult.getString(1)+"--"+recresult.getString(2)%></option>

<%}%>
</select> </td> </tr>


<%
conn1.close();
%>

...

id is the first column and description is the next, the listbox should show both the id and the description to the user but the id column should go into the database..

with this code, the page loads but this list box doesnt show on the page...

what to do?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check the source of generated page.
if not then I would recommend to check the source and make a HTML file from generated source and check what is error ?

most likely their is some character which is causing listbox not to be displayed

Shailesh
[ July 14, 2005: Message edited by: Shailesh Chandra ]
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maria,

try to assign rs.getString(1) to a String and execute.
I think it works

Srilakshmi
 
maria pasha
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is working now!
 
maria pasha
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how does one create a listbox in which a user can type values and that value comes up from the dropdown?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

yes it is working now!


you didn't tell what was probelm and how did you solve that ?


how does one create a listbox in which a user can type values and that value comes up from the dropdown?


Could you explain this in detail ?

Shailesh
 
maria pasha
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean an editable dropdown....in which a user can also type in values...
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by maria pasha:
yes it is working now!


Each of the getters in ResultSet should only be called once, and preferrably in order. It is a good practice to always assign them to attributes and then refer to the attibutes when you need the values. From the API:

For maximum portability, result set columns within each row should be read in left-to-right order, and each column should be read only once.

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic