• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

combo box selection in jsp

 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Smarty pants! OK, I've changed it to "newbie"!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic