Answer the question
In order to leave comments, you need to log in
How to fix calculator in JS?
Hello everyone, dear friends! I turn to you with a request for help. I have a calculator on the site, the view is as follows:
function changeText0(){
var res = 1;
var a = parseFloat(document.getElementById('a').value);
var b = parseFloat(document.getElementById('b').value);
var c = parseFloat(document.getElementById('c').value);
var d = parseFloat(document.getElementById('d').value);
if (document.getElementById('c').checked)
res = a + b + c;
if (document.getElementById('d').checked)
res = a + b + d;
document.getElementById('res').innerHTML = res;
}
<form onsubmit="return false;" oninput="changeText0()">
<label>Площадь здания</label><br>
<input id="a" type="number" min="0"><br>
<label>Количество помещений в здании</label><br>
<input id="b" type="number" min="0"><br>
<label>Тип потолка:</label><br>
<input id="c" type="radio" name="potolok" value="100"> Армстронг<Br>
<input id="d" type="radio" name="potolok" value="200"> Другой<Br>
<label>Цена:</label><br>
<output id="res">0</output>
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question