I am having a input type=range
and need to know which tickmark index my slider has to get some values out of an array.
var slider = document.getElementById("myRange");
var output = document.getElementById("output");
var repaymentsInfo = document.getElementById("repayments");
var requiredIncome = document.getElementById("income");
var ticks = document.getElementsByTagName("option");
var repayList = [];
var incomeList = [];
for (var i = 0; i < ticks.length; i++){
repayList.push(data[i].repaymentsPerMonth)
incomeList.push(data[i].requiredAnnualIncome)
}
slider.oninput = function(){
output.innerHTML = this.value;
repaymentsInfo.innerHTML = repayList[**index**];
requiredIncome.innerHTML = incomeList[**index**];
};
slider.oninput();`
I tried all the possible attributes of slider.oninput
, but I can't find the solution how to extract the current index of my slider point.