ok, I’ve made a calculator that puts the values entered in the input fields in a formula. But somethings is reaallly wrong, it either displays something like 34543… or “NaN”.. If all the inputs are 99 (which they’re by default) it should show 138.6; but it doesn’t ? I need help, please. ? (I’ve done the same thing in php and it works there; but I want to do it in JS because then I can make an interactive form. (Idk, how to use ajax)).
You can see the code in action [URL=”http://www.11sta.com/calc.htm”]Here
The code is here:
[CODE]<html>
<head>
<script type=”text/javascript”>
function calc1()
{
var inp1=document.getElementById(‘inp1’).value;
var inp2=document.getElementById(‘inp2’).value;
var inp3=document.getElementById(‘inp3’).value;
var inp4=document.getElementById(‘inp4’).value;
var inp5=document.getElementById(‘inp5’).value;
var inp6=document.getElementById(‘inp6’).value;
document.getElementById(‘ost’).value=0.25*(1.3*(inp1+inp2)+inp3+inp4+(0.5*inp5)+(0.5*inp6));
}
</script>
</head>
<body>
<form>
<input type=”text” id=”inp1″ onkeyup=”calc1()” size=”3″ value=”99″><br />
<input type=”text” id=”inp2″ onkeyup=”calc1()” size=”3″ value=”99″><br />
<input type=”text” id=”inp3″ onkeyup=”calc1()” size=”3″ value=”99″><br />
<input type=”text” id=”inp4″ onkeyup=”calc1()” size=”3″ value=”99″><br />
<input type=”text” id=”inp5″ onkeyup=”calc1()” size=”3″ value=”99″><br />
<input type=”text” id=”inp6″ onkeyup=”calc1()” size=”3″ value=”99″><br />
</form>
<input type=”text” id=”ost” size=”5″>
</body>
</html>