J
jason
The following (likely far from imperfect code), reports a value of NaN
in the j4 display. I suppose the problem is I am not really passing
the "checked" value of the radio button via .value ... without having
to get this value via html, is there any way I can passed the checked
value via html .. maybe with syntax like n4.checked.value or
something..
Many thanks.
<html>
<body>
WIDTH: <input type=text name=n1 value=5>
<br>
LENGTH:<input type=text id=n2 value=10>
<br>
EXTRA:<input type=text id=n3 value=20>
<br>
<br>
CHOOSE STYLE:
<br>
<input type="radio" checked name=n4 value=3>Green
<input type="radio" name=n4 value=5>Red
<input type="radio" name=n4 value=7>Blue
<br>
<br>
<input type=button value="Calulate Estimate"
onclick="mmm(n1.value,n2.value,n3.value,n4.value)">
<br>
<br>
<br>
<br>
TOTAL COST:
<input type=text id=t value=0>
<script defer>
function mmm(x1,x2,x3,x4) {
var j1 = +x1;
var j2 = +x2;
var j3 = +x3;
var j4 = +x4;
alert(j4);
var d=document;
var el=d.getElementById("t");
el.value=Math.round(((j1*j2)+j3)*j4);
}
</script>
</body>
</html>
in the j4 display. I suppose the problem is I am not really passing
the "checked" value of the radio button via .value ... without having
to get this value via html, is there any way I can passed the checked
value via html .. maybe with syntax like n4.checked.value or
something..
Many thanks.
<html>
<body>
WIDTH: <input type=text name=n1 value=5>
<br>
LENGTH:<input type=text id=n2 value=10>
<br>
EXTRA:<input type=text id=n3 value=20>
<br>
<br>
CHOOSE STYLE:
<br>
<input type="radio" checked name=n4 value=3>Green
<input type="radio" name=n4 value=5>Red
<input type="radio" name=n4 value=7>Blue
<br>
<br>
<input type=button value="Calulate Estimate"
onclick="mmm(n1.value,n2.value,n3.value,n4.value)">
<br>
<br>
<br>
<br>
TOTAL COST:
<input type=text id=t value=0>
<script defer>
function mmm(x1,x2,x3,x4) {
var j1 = +x1;
var j2 = +x2;
var j3 = +x3;
var j4 = +x4;
alert(j4);
var d=document;
var el=d.getElementById("t");
el.value=Math.round(((j1*j2)+j3)*j4);
}
</script>
</body>
</html>