wood burning stoves 2.0*
The moose likes JDBC and the fly likes listbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "listbox" Watch "listbox" New topic
Author

listbox

maria pasha
Greenhorn

Joined: Jun 28, 2005
Posts: 11
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

Joined: Aug 13, 2004
Posts: 1081

what is your existing code, please paste your code here ?

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
maria pasha
Greenhorn

Joined: Jun 28, 2005
Posts: 11
.....

<%
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

Joined: Aug 13, 2004
Posts: 1081

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

Joined: Jul 21, 2004
Posts: 169
Hi Maria,

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

Srilakshmi
maria pasha
Greenhorn

Joined: Jun 28, 2005
Posts: 11
yes it is working now!
maria pasha
Greenhorn

Joined: Jun 28, 2005
Posts: 11
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

Joined: Aug 13, 2004
Posts: 1081


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

Joined: Jun 28, 2005
Posts: 11
i mean an editable dropdown....in which a user can also type in values...
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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
 
subject: listbox