Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spin through listbox items and update selection status

 
nebber johnson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form that contains several elements populated based on a database query. One such field is a list of employees which is basically the result of a select * sql. The listbox is correctly populated

The issue I'm having is that on a "edit" page I have a query that returns a specific record (lets say joe's record). What I need to do is spin through the list of possible items (Jack, Joe, Mary) and if the value matches the name returned in the second query then make the item selected. Here is how I think it would be done:
1) Populate listbox with all possible items
2) Select a specific transaction and return a name
3) Spin through listbox items and if the item value match the name then mark it selected.

Is this possible to do and if so how?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just do it all while you're building the element?
 
nebber johnson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mainly because it is two different SQLs. But your suggestion is a good one, I believe I can store the results of the specific fetch and compare the "all" fetch with those results to populate.

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be performing all database operations long before you get to the JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic