B
beavenour
I am looking for some help creating a more universal function out of
this lame attempt at javascript. I have little experience with
javascript and want to be able to universalize this function. So how
do I change this script so that I can call any field or any number of
fields to be totaled? For example - calculate(myfield01, myfield02)
at one total field and calculate(myfield06, myfield08, myfield11) at
another total field instead of creating a whole new function to do
each. Any help or suggestions would be very much apprectated.
<SCRIPT language = JavaScript>
function calculate() {
a = parseInt(document.myform.myfield01.value);
b = parseInt(document.myform.myfield02.value);
c = parseInt(document.myform.myfield03.value);
d = parseInt(document.myform.myfield04.value);
z = Math.round((a + b + c + d)*100)/100;
document.myform.total.value = z;
}
</SCRIPT>
this lame attempt at javascript. I have little experience with
javascript and want to be able to universalize this function. So how
do I change this script so that I can call any field or any number of
fields to be totaled? For example - calculate(myfield01, myfield02)
at one total field and calculate(myfield06, myfield08, myfield11) at
another total field instead of creating a whole new function to do
each. Any help or suggestions would be very much apprectated.
<SCRIPT language = JavaScript>
function calculate() {
a = parseInt(document.myform.myfield01.value);
b = parseInt(document.myform.myfield02.value);
c = parseInt(document.myform.myfield03.value);
d = parseInt(document.myform.myfield04.value);
z = Math.round((a + b + c + d)*100)/100;
document.myform.total.value = z;
}
</SCRIPT>