Derek Derek - 4 months ago 21
Javascript Question

Jquery slider UI issue

Im having trouble with the min and max values of the jQuery Slider UI. I set the min value to 5000 and the max value to 1000000 with 25000 step increments. However when I view it on the front-end I get the following:

enter image description here

Here is my code:

$( "#slider-range" ).slider({
range: true,
step:25000,
min: 5000,
max: 1000000,
values: [ 5000, 1000000 ],
slide: function( event, ui ) {
$( "#657401867-MinPrice" ).val( (ui.values[ 0 ] + "").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") );
//$( "#MinPrice" ).text( ui.values[ 0 ] );
$( "#657401867-MaxPrice" ).val( (ui.values[ 1 ] + "").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") );
//$( "#MaxPrice" ).text( ui.values[ 1 ] ); ($( "#slider-range" ).slider( "values", 0 ) + "").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}
});


So for some reason, on the front end it has the max value as 980,000 instead of 1,000,000.

Answer

This is probably because the step value is 25,000. If you increment your min of 5,000 by 25,000, the largest possible value is 980,000, since your max is 1,000,000. I'd recommend changing the step value to 5,000 to solve this issue.

Comments