This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes drop down menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "drop down menu" Watch "drop down menu" New topic

drop down menu

Anil Dubey

Joined: Dec 11, 2008
Posts: 4
Hello everyone.

I am trying to create a drop down menu using JSP. The content of the menu should be fetched from a column in the table. For example;

Table name: week
Column name: days
Days has (mon, tue, wed, thurs, fri, sat, sun)

now i want to make a drop down such that it would fetch from table week and put in the days as the content of the drop down.
Any suggestions or help will be much appreciated.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60785

What have you got so far? DO you have the HTML and JavaScript that defines the menu designed? Until you know what it is you want to build, it's not time to think about the JSP to build it.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
These tables, are they DB tables or html tables?
Anil Dubey

Joined: Dec 11, 2008
Posts: 4
The table exist in the Oracle sql server.
Also this is a small part of a complex issue.
onclick of a button i have a window pop up and this window should have the drop down menu.
based on the user selection of the day i am running a stored procedure.

Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
That looks pretty simple [or is it just me] - just some plain javascript should do the trick.

On click of the button, make sure you have an attribute "target=_blank" so that the response opens in a new window. Rest is just usual server side code... you fetch the data, and populate it in whatever UI component you need it to.
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

Okay. So first design the HTML which is going to contain that drop-down. You know what HTML element you're going to use, right? (If not then that's the first thing to find out.) Write out an example with a couple of entries in it.

Once you have that, then you know what your JSP should be generating. But it needs some input to work from. So you should have a servlet that extracts the data required to produce the drop-down and puts it in a list of objects. Add that list to the request scope and forward to the JSP. The JSP will contain some JSTL code to produce the drop-down from that list.

That's just a general description. But hopefully you can see that there's several different parts of the design. Don't try to do them all in one lump, do them separately. It may happen that you have to redo one part of your design when you find in some other part that there's something missing, but that's normal in the design process.
Anil Dubey

Joined: Dec 11, 2008
Posts: 4
Thanks guys..

I am going to attempt all those and let you all know how it went.

Thanks for all the suggestions
Don't get me started about those stupid light bulbs.
subject: drop down menu
Similar Threads
retrieve data from database
JSP form problem
What is the syntax for a "drop down menu"?
accessing database using javascript
JSP/JDBC problem...please help!!!!