I've installed noUiSlider and I am trying to make it so when you slide it it calls a function to update a second input textbox.
My end goal is to make it work like on this page where you can type a number and it sets the slider to it or vice versa, but I can't figure out how to make it work with only one tooltip.
Currently it plugs the value from the slider into the CAD textbox perfectly but I also want it to convert it into the BTC equivalent amount using this function I wrote: (cant post a jsfiddle because the code for noUiSlider is too long)
function cadConvert() {
var cad = document.getElementById("cadc").value;
var cadCalc = cad / price;
var cadCalc = cadCalc.toFixed(8);
document.getElementById("btcc").value = cadCalc;
cadCheck();
}
The code for the slider is here:
var directionSlider = document.getElementById('slider-direction');
noUiSlider.create(directionSlider, {
start: 20,
connect: [true, false],
direction: 'ltr',
range: {
'min': 2,
'max': 99.99
}
});
var inputFormat = document.getElementById('cadc');
directionSlider.noUiSlider.on('update', function( values, handle ) {
inputFormat.value = values[handle];
cadConvert();
});
directionSlider.addEventListener('change', function(){
sliderFormat.noUiSlider.set(this.value);
cadConvert();
});