aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes how to order a combo box with numbers in it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to order a combo box with numbers in it" Watch "how to order a combo box with numbers in it" New topic
Author

how to order a combo box with numbers in it

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
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

Joined: Jan 10, 2002
Posts: 61433
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
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

Joined: Jan 10, 2002
Posts: 61433
    
  67

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

Joined: Oct 27, 2010
Posts: 421


I changed it and it still does the same thing.

Any thoughts about this?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
The elements are displayed the order they are added to the element. How are you adding them?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to order a combo box with numbers in it