我需要一个 JavaScript 计算器,它将第一个输入值乘以 0.04,第二个输入乘以 0.04,第三个输入乘以 0.08,然后将它们加在一起并回显。它还应该回显三个输入的数量。
HTML:
<form method="post" name="vaartus">
<div>1<input type="checkbox" id="v1" /></div>
<div><input type="text" name="v1_v" id="v1_v" disabled="disabled" /></div>
<div>2<input type="checkbox" id="v2" /></div>
<div><input type="text" name="v2_v" id= "v2_v" disabled="disabled" /></div>
<div>3<input type="checkbox" id="v3" /></div>
<div><input type="text" name="v3_v" id="v3_v" disabled="disabled" /></div>
<div><input type="submit" name="arvuta" value="Arvuta" /></div>
</form>
JavaScript:
document.getElementById('v1').onchange = function() {
document.getElementById('v1_v').disabled = this.unchecked;
};
document.getElementById('v2').onchange = function() {
document.getElementById('v2_v').disabled = this.unchecked;
};
document.getElementById('v3').onchange = function() {
document.getElementById('v3_v').disabled = this.unchecked;
};