kamaci
kamaci

Reputation: 75137

Spinner with JQuery or Javascript or HTML?

I want to write a spinner code at javascript/jQuery to get minute and hour from user.

I want to implement this with Jquery or Javascript or HTML:

enter image description here

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?

Upvotes: 1

Views: 2521

Answers (2)

Joyrex
Joyrex

Reputation: 1103

I've really liked Keith Wood's take on date and time entry:

http://keith-wood.name/timeEntry.html

Upvotes: 1

David Tang
David Tang

Reputation: 93664

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/

Upvotes: 3

Related Questions