tonelm54
asked on
Drop down box in order
Ive got some simple code to populate a select box with the hours of the day:-
Which works great however the drop down populates like:-
But I want it to populate as:-
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
$.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));
});
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help