I'm using jQuery UI sliders to set values in text boxes. I'd like this to work both ways though, so, if a value is placed in the a text box, I'd like the slider to move to the relevant position.
I'm not certain on the best solution for this though.
I have the following markup:
<label for="amount-depoist">Deposit Amount (£):</label>
<input type="text" id="amount-deposit" >
<div id="slider-deposit"></div>
And the following jQuery:
jQuery( document ).ready(function( $ ) {
$( "#slider-deposit" ).slider({
range: "min",
value: 100,
min: 0.1,
max: 0.7,
step: 1,
slide: function( event, ui ) {
$( "#amount-deposit" ).val(Number(ui.value).toFixed(2));
totalPayableFunc();
monthlyPaymentsFunc();
}
});
$( "#amount-deposit" ).val(Number($( "#slider-deposit" ).slider( "value" )).toFixed(2));
totalPayableFunc();
monthlyPaymentsFunc();
});
Currently on on the slider slide: function some functions are called that 'do maths' and a value is set in the amount-deposit text input field. I'd like this text input field to be editable so on keyup the slider will slide to the relevant position. I'm unsure on how I might achieve this though, could anyone some advice.
I have a JS fiddle here: https://jsfiddle.net/liamrfell/nzzb8nad/1/