function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } var sel = document.querySelector("select"); sel.addEventListener("change", function() { var val = sel.selectedOptions[0].id.split('-') sel.selectedOptions[0].value = getRandomInt(+val[0], +val[1]) setInterval(function() { sel.selectedOptions[0].value = getRandomInt(+val[0], +val[1]) }, 5000); console.log(sel.value); }) <select id="periodicity"> <option id="1-60" value="">Одуванчик </option> <option id="25-70" value="">Чабрец </option> <option id="1-100" value="">Полынь </option> </select> Help with setInterval need to update the value every 5 seconds
console.log()inserted intosetInterval()?)) - entithatchangeevent, an additional timer will be triggered. - IgorgetRandomIntfunctiongetRandomIntnever return themaxvalue. - Dmytryk