I am trying to make a range slider using jQuery's UI Slider and i was wondering how i could make the two knobs to move together. For example i have minimum value at 0 and maximum at 100 the total value of these two must not be more than 60 so if the first knob is at 10 the other can go till 70 . No here is the problem how we could move the second knob to go lets say to 80 and the forst knob to go at 20 so by dragging the second knob i would move the first keeping their distance.
Thank you very much
function generate_slider(video_duration) {
start_duration = 0
end_duration = 60
if(video_duration < 60){
end_duration = video_duration;
}
$("#slider-range").slider({
range: true,
min: 0,
max: video_duration,
values: [start_duration, end_duration],
slide: function (event, ui) {
total_duration = (ui.values[1] - ui.values[0])
if (total_duration > 60) {
return false;
} else {
$("#amount").val("From: " + ui.values[0] + "sec" + " - To: " + ui.values[1] + "sec");
$("#total_amount").val("Selected:" + total_duration + " out of " + video_duration + " Sec");
}
$("#" + prefix + "hdn_duration").val(video_duration);
$("#" + prefix + "hdn_duration_total").val(total_duration);
$("#" + prefix + "hdn_duration_from").val(ui.values[0]);
$("#" + prefix + "hdn_duration_to").val(ui.values[1]);
}
});
$("#amount").val("From: " + $("#slider-range").slider("values", 0) + "sec" + " - To: " + $("#slider-range").slider("values", 1) + "sec" );
$("#total_amount").val("Selected:" + ($("#slider-range").slider("values", 1) - $("#slider-range").slider("values", 0)) + " out of " + video_duration + " Sec");
$("#" + prefix + "hdn_duration").val(video_duration);
$("#" + prefix + "hdn_duration_total").val($("#slider-range").slider("values", 1) - $("#slider-range").slider("values", 0));
$("#" + prefix + "hdn_duration_from").val($("#slider-range").slider("values", 0));
$("#" + prefix + "hdn_duration_to").val($("#slider-range").slider("values", 1));
}