Solved

Drop down box in order

Posted on 2013-05-31
3
233 Views
Last Modified: 2013-06-18
Ive got some simple code to populate a select box with the hours of the day:-
        $.each({"00":"00", "01":"01", "02":"02", "03":"03", "04":"04", "05":"05", "06":"06", "07":"07", "08":"08", "09":"09", "10":"10", "11":"11", "12":"12", "13":"13", "14":"14", "15":"15", "16":"16", "17":"17", "18":"18", "19":"19", "20":"20", "21":"21", "22":"22", "23":"23" }, function(key, value) {
            $('.ddHH')
                .append($('<option>', { value : key })
                .text(value));
            });

Open in new window


Which works great however the drop down populates like:-
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 00, 01, 02, 03, 04, 05, 06, 07, 08, 09

But I want it to populate as:-
00, 01, 02, 03, 04, 05, 06, 07, 08, 0910, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23

I dont understand where the 'sorting' is coming in, as surely it would just take the first element of the array add it, then the second. I would understand if it was reveresed, but dont understand this :-(

Any ideas?

Thank you
0
Comment
Question by:tonelm54
3 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 39210890
0
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
ID: 39211078
Your code works fine for me.
http://jsfiddle.net/Sqqbg/1/
0
 

Author Closing Comment

by:tonelm54
ID: 39257095
Hmm, dont understand then, must be me :-S

Thanks for your help
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now