aspose file tools*
The moose likes JSP and the fly likes combo box selection in jsp 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 » JSP
Bookmark "combo box selection in jsp" Watch "combo box selection in jsp" New topic
Author

combo box selection in jsp

Tom Joiner
Ranch Hand

Joined: Sep 19, 2006
Posts: 47
I am using a combo box, and wish to indicate which item has been selected.

Here is the code I am using:


Is there a more elegant way to do this?


SCJP
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

A few.

If you're using a JSP 2.0 engine, the Expression Language is always preferred over scriptlets.

If not, you could use the ternary operator in a scriptlet expression:



I also use xhtml rules so I'd opt for selected="selected" as the attribute. But that's up to you.

Oh, and it's not really a "combo box". I'm not sure why so many people call it that. A "combo box" is a desktop control that allows either selection from a dropwdown list or typing a value into the control. That's where "combo" comes in. HTML does not provide for this type of control. You'll appear less of a newbie if you call it a "select element" or "dropdown" or "droplist".
[ November 09, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Bear Bibeault:
You'll appear less of a n00b if you call it a "select element" or "dropdown" or "droplist".


Bear Bibeault,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
UseRealWords


Abbreviations such as "u" or "ur" in
place of "you" and "you are" or "you're" confound language translation software making
it hard for our non-English speaking members to read your posts.
"n00b" is not a word in the English language.

Again, welcome to JavaRanch and good luck with your question.
-Ben

[ November 09, 2006: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Smarty pants! OK, I've changed it to "newbie"!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: combo box selection in jsp
 
Similar Threads
urgent...select ....option... doubt
Script using array
Implementing Dojo
Selecting a value in a combo box that equals the value from the database record?
populate combox with list with default selected value