All,
Below find my JS which is supposed to do the following:
Take user supplied numerical values from 7 fields, perform the calculation function that's in the code and place it into the Total box / field.
Needless to say ...or I wouldn't be here...it doesn't work.
I thought maybe the problem was in the function, but I'm not sure
Thanks to all who can help!
NewbieScott
================================
<html>
<head>
<title>Test Prototype</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background:#fff;
}
p {
margin:2em;
}
</style>
<script type="text/javascript">
function calc(D1,D2,D3,D4,D5,D6,D7){
return (((D1*2.036+D3)/(273+D5))-((D2*2.036+D4)/(273+D6)))*238*(3050/D7);
var D1=parseInt(D1.value);
var D2=parseInt(D2.value);
var D3=parseInt(D3.value);
var D4=parseInt(D4.value);
var D5=parseInt(D5.value);
var D6=parseInt(D6.value);
var D7=parseInt(D7.value);
if (isNaN(D1)) {D1=0;}
if (isNaN(D2)) {D2=0;}
if (isNaN(D3)) {D3=0;}
if (isNaN(D4)) {D4=0;}
if (isNaN(D5)) {D5=0;}
if (isNaN(D6)) {D6=0;}
if (isNaN(D7)) {D7=0;}
document.getElementById('total').value = D1+D2+D3+D4+D5+D6+D7;
}
window.onload=function() {
var D1=document.getElementById('D1');
var D2=document.getElementById('D2');
var D3=document.getElementById('D3');
var D4=document.getElementById('D4');
var D5=document.getElementById('D5');
var D6=document.getElementById('D6');
var D7=document.getElementById('D7');
D1.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D2.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D3.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D4.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D5.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D6.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D7.onkeyup=function() {calc(D1,D2,D3,D4,D5,D6,D7);
}
</script>
</head>
<body>
<form action="#">
<p><label> Number 1: <input id="D1"></label>
<p><label> Number 2: <input id="D2"></label>
<p><label> Number 3: <input id="D3"></label>
<p><label> Number 4: <input id="D4"></label>
<p><label> Number 5: <input id="D5"></label>
<p><label> Number 6: <input id="D6"></label>
<p><label> Number 7: <input id="D7"></label>
<p>Total = <input id="total"></p>
</p>
</body>
</html>
Below find my JS which is supposed to do the following:
Take user supplied numerical values from 7 fields, perform the calculation function that's in the code and place it into the Total box / field.
Needless to say ...or I wouldn't be here...it doesn't work.
I thought maybe the problem was in the function, but I'm not sure
Thanks to all who can help!
NewbieScott
================================
<html>
<head>
<title>Test Prototype</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background:#fff;
}
p {
margin:2em;
}
</style>
<script type="text/javascript">
function calc(D1,D2,D3,D4,D5,D6,D7){
return (((D1*2.036+D3)/(273+D5))-((D2*2.036+D4)/(273+D6)))*238*(3050/D7);
var D1=parseInt(D1.value);
var D2=parseInt(D2.value);
var D3=parseInt(D3.value);
var D4=parseInt(D4.value);
var D5=parseInt(D5.value);
var D6=parseInt(D6.value);
var D7=parseInt(D7.value);
if (isNaN(D1)) {D1=0;}
if (isNaN(D2)) {D2=0;}
if (isNaN(D3)) {D3=0;}
if (isNaN(D4)) {D4=0;}
if (isNaN(D5)) {D5=0;}
if (isNaN(D6)) {D6=0;}
if (isNaN(D7)) {D7=0;}
document.getElementById('total').value = D1+D2+D3+D4+D5+D6+D7;
}
window.onload=function() {
var D1=document.getElementById('D1');
var D2=document.getElementById('D2');
var D3=document.getElementById('D3');
var D4=document.getElementById('D4');
var D5=document.getElementById('D5');
var D6=document.getElementById('D6');
var D7=document.getElementById('D7');
D1.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D2.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D3.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D4.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D5.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D6.onkeyup=function() {calc(D1,D2,D3,D4,D4,D6,D7);
D7.onkeyup=function() {calc(D1,D2,D3,D4,D5,D6,D7);
}
</script>
</head>
<body>
<form action="#">
<p><label> Number 1: <input id="D1"></label>
<p><label> Number 2: <input id="D2"></label>
<p><label> Number 3: <input id="D3"></label>
<p><label> Number 4: <input id="D4"></label>
<p><label> Number 5: <input id="D5"></label>
<p><label> Number 6: <input id="D6"></label>
<p><label> Number 7: <input id="D7"></label>
<p>Total = <input id="total"></p>
</p>
</body>
</html>