Возвращаясь к самому началу темы....
<div>
Период <select id="period">
<option value = "25">25</option>
<option value = "20">20</option>
<option value = "15">15</option>
<option value = "10">10</option>
</select>
<br>
Сумма депозита <input type="text" id="deposit" class = "onlyDigits" value="10"/><br>
<input type="button" onclick="summ();" value="Расчет" >
</div>
<div id="debet" ></div>
<div id="summa"></div>
<script>
var debet= [{percent: 2, period: 25, min: 10, max:500},{percent: 3.3, period: 20, min: 510, max:5000},{percent: 4.5, period: 15, min: 5010, max:10000},{percent: 6.3, period: 10, min: 10010, max:100000}],
minDebet = 10,
maxDebet = 500,
percent = 2;
function onlyDigits() {
this.value = this.value.replace(/[^\d]/g, "");
document.querySelector("#debet").innerHTML = " ";
document.querySelector("#summa").innerHTML = "";
}
document.querySelector(".onlyDigits").oninput = onlyDigits;
function summ() {
var dep = document.querySelector('#deposit'),
depv = +dep.value;
if(depv < minDebet) dep.value = minDebet.toString();
if(depv > maxDebet) dep.value = maxDebet.toString();
depv = +dep.value;
var period = document.querySelector("#period").value;
var result = (depv * percent * period / 100);
document.querySelector("#debet").innerHTML = "Доход: " + result;
document.querySelector("#summa").innerHTML = "Итого: " + (result + depv);
}
document.querySelector("#period").onchange = function() {
var period = +this.value;
for(var i = 0; i < debet.length; i++) {
if(debet[i].period == period) {
minDebet = debet[i].min;
maxDebet = debet[i].max;
percent = debet[i].percent;
document.querySelector("#deposit").value = minDebet.toString();
document.querySelector("#debet").innerHTML = " ";
document.querySelector("#summa").innerHTML = "";
}
}
}
</script>