1 回答
TA贡献1844条经验 获得超8个赞
如果您想在贷款期限字段的每次更改时更新利率字段,那么这里是如何做的
var ratesValue = document.querySelector("#rates");
document.querySelector("#dureeInputId").onchange = function() {
if(this.value >= 2 && this.value <= 9) {
ratesValue.value = 0.75;
}else if(this.value >= 10 && this.value <= 11) {
ratesValue.value = 0.9;
}else if(this.value >= 12 && this.value <= 14) {
ratesValue.value = 1;
}else if(this.value >= 15 && this.value <= 19) {
ratesValue.value = 1.1;
}else if(this.value >= 20 && this.value <= 24) {
ratesValue.value = 1.3;
}else if(this.value >= 25 && this.value <= 29) {
ratesValue.value = 1.65;
}else {
ratesValue.value = 2.18;
}
};
<div class="loans-simulator">
<label for="duration">Loan duration</label>
<input type="range" name="dureeInputName" id="dureeInputId" value="2" min="2" max="30" oninput="dureeOutputId.value = dureeInputId.value" onchange="updateTextInput(this.value);">
<input name="dureeOutputName" id="dureeOutputId" value="2"><br/>
<label for="rates">Rate %</label>
<input id="rates" value="0.75" step=".01" min="0.0">
</div>
添加回答
举报