Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to order a combo box with numbers in it

 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I have a plug and play app that uses the following code:


When I test this app, I keep testing and selecting "1" (there are 10 districts).

The first number in the combo box, which is dynamic, is "2".

How do I get this combo box to filter?

Any suggestions appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michele Smith wrote:How do I get this combo box to filter?

I do not know what you mean by that.

If you want a specific order to the option elements, be sure that they are added to the select element in the desired order.
 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I am testing it and no matter what I select, (i.e., 1-10), it always defaults to "2".

I don't understand why.

The application is WYSIWYG, but then it spawns an HTML window you can modify.

I wondered how most people go about ordering a combo box that contains numbers only, if the combo box by default, says something like this: 2, 3, 1, 4, 5, etc.

Thanks,
Michele
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will default to the first option element if no option element is marked as selected. Add selected to the option element that you want to be initially selected.

Again, if you want them in a specific order, the options must be placed in that order.
 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I changed it and it still does the same thing.

Any thoughts about this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your placed the selected on the select element; it must go on the option element that is to be selected.

You code doesn't show any option elements. I can only assume that they must be added by script elsewhere? Whatever adds them needs to add them in the order you want, and placing the selected attribute on the one to be selected.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The elements are displayed the order they are added to the element. How are you adding them?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic