J
J. Hall
Hi dudes,
Got a simple webpage, with three numeric text input boxes, the idea being
that the user is asked to insert percentages of their business around the
world...
UK, Europe, Other
Obviously this mustn't exceed 100% and so I OnChange I simply want to check
that all three boxes have a value, and if so sum them up and alert the user
is the sum exceeds 100!
I have constructed the function below that WORKS but ONLY IF I remove the
underscores from the Form Name and Input Boxes!? I'm totally confused by
this, I haven't had this occurance before, and so I'm wondering if
underscores are allowed in functions?
Finally, how do I add an IF statement before the main IF statement to check
for values in all three boxes?
Many thanks!
Please help!
-------------------------------
function Ash_CalculatePercentageTotal() {
Num1 = document.form_addnewclient.Q_TurnoverPercentUK.value;
Num2 = document.form_addnewclient.Q_TurnoverPercentEurope.value;
Num3 = document.form_addnewclient.Q_TurnoverPercentOther.value;
alert('For debugging: ' + Num1 + ' ' + Num2 + ' ' + Num3)
if (eval(Number(Num1)+Number(Num2)+Number(Num3)) > 100) {
alert('Please check the percentages entered, they must add up to 100%')
}
}
Got a simple webpage, with three numeric text input boxes, the idea being
that the user is asked to insert percentages of their business around the
world...
UK, Europe, Other
Obviously this mustn't exceed 100% and so I OnChange I simply want to check
that all three boxes have a value, and if so sum them up and alert the user
is the sum exceeds 100!
I have constructed the function below that WORKS but ONLY IF I remove the
underscores from the Form Name and Input Boxes!? I'm totally confused by
this, I haven't had this occurance before, and so I'm wondering if
underscores are allowed in functions?
Finally, how do I add an IF statement before the main IF statement to check
for values in all three boxes?
Many thanks!
Please help!
-------------------------------
function Ash_CalculatePercentageTotal() {
Num1 = document.form_addnewclient.Q_TurnoverPercentUK.value;
Num2 = document.form_addnewclient.Q_TurnoverPercentEurope.value;
Num3 = document.form_addnewclient.Q_TurnoverPercentOther.value;
alert('For debugging: ' + Num1 + ' ' + Num2 + ' ' + Num3)
if (eval(Number(Num1)+Number(Num2)+Number(Num3)) > 100) {
alert('Please check the percentages entered, they must add up to 100%')
}
}