This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes ComoboBox values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ComoboBox values" Watch "ComoboBox values" New topic
Author

ComoboBox values

Nick Howell
Greenhorn

Joined: Mar 28, 2002
Posts: 26
I was wondering if anyone oculd tell me if there was a way to assign values to combo box items so that when the user selects an item I can immediately reference the numeric value of the item. Like in html where you write:
<select>
<option value="12345">Option A</option>
<option value="67890">Option B</option>
</select>
I know how to read the item text or selected index and then use a conditional statement but that seems like a lot of unnecessary work. Thanks.


Thanks.<br />-Nick
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
You can put whatever type of object you desire in a ComboBox. You could put a custom type of object in it that has a name and a value:

You would then use

And you could make the value any type that you want. It wouldn't have to be a String.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ComoboBox values
 
Similar Threads
drop down list space problem
jquery newbie question on select element
html:select and html:options question
html:options horrible default settings
Populating each row of a Column with combo boxes containing values from database