I’m trying to use a JQuery UI slider to allow users to select a 24 hour time.
I’m using this code from question: JQuery UI Slider for time
$(function() {
$(".slider_start_time").slider({
range: true,
min: 0,
max: 1440,
step: 15,
slide: function(e, ui) {
var hours = Math.floor(ui.value / 60);
var minutes = ui.value - (hours * 60);
if(hours.length == 1) hours = '0' + hours;
if(minutes.length == 1) minutes = '0' + minutes;
$('#start_time_text').val(hours+':'+minutes);
}
});
});
But I get an error: b is null???
Some sort of mousedown error when trying to drag the slider maybe?
Any help would be much apprectiated! Thanks!
I have no error on “b”, here is a fiddle: http://jsfiddle.net/IrvinDominin/RYx54/.
Can you provide more code?
What kind of slider do you need to use?
http://jqueryui.com/demos/slider/#range
With range you can capture a range of values with two drag handles. The space between the handles is filled with a different background color to indicate those values are selected.
http://jqueryui.com/demos/slider/#rangemax
Fix the maximum value of the range slider so that the user can only select a minimum. Set the range option to “max.”
EDIT:
the two options have different setup and use: http://jsfiddle.net/IrvinDominin/RYx54/1/
the right choice depends on your needs.