Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Drop down box in order

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
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tonelm54
tonelm54

ASKER

Hmm, dont understand then, must be me :-S

Thanks for your help