I want to write a spinner code at javascript/jQuery to get minute and hour fr开发者_高级运维om user.
I want to implement this with Jquery or Javascript or HTML:
I have implemented the calendar part (at left at screenshot) with JQuery datepicker. There are two spinners over there and hour range is from 00 to 23. Minute range is 00 to 59.
How can I do it?
What's in the screenshot isn't exactly a spinner - it's just a <select>
with the values from 00
to 59
filled in.
With jQuery:
var select = $('#minute');
for (var i = 0; i < 60; i++) {
$('<option>', {
value: i,
text: (i < 10 ? '0' + i : i)
}).appendTo(select);
}
You'll also need this HTML in your form:
<select id="minute"></select>
Here is a demo: http://jsfiddle.net/yhmAT/
I've really liked Keith Wood's take on date and time entry:
http://keith-wood.name/timeEntry.html
精彩评论