Hi all ...
Let me first of all warn you I'm not really good a Javascript (jet) [img]images/smilies/xeye.gif[/img]
I want to calculate a total for a form and alert if some conditions aren't met ...
I'm going completely crazy here ... so any help would be appreciated.. here's the deal ..
there is 4 input's with name A - D their values need to be between 0 -50 and the total must be 50 exactly .....
this is what I got so far
PHP Code:
function Optellen()
{
var total
total = 0
A = document.CQS.A.value
B = document.CQS.B.value
C = document.CQS.C.value
D = document.CQS.D.value
if(A = '' ) { A = 0 }
if(B = '' ) { B = 0 }
if(C = '' ) { C = 0 }
if(D = '' ) { D = 0 }
total += eval(A)
total += eval(B)
total += eval(C)
total += eval(D)
if (total > 50)
{
alert("The total can not be more than 50" )
}
else
{
document.CQS.total.value = total
}
}
1 there must be an easier way .. two I keep getting NaN as an answer...
Please help
Edit:
I'm using the PHP code tag so I get nice outlined code but ofcourse it's javascript
Bookmarks