Click to See Complete Forum and Search --> : Total results from a script
gdevo
07-08-2003, 12:36 PM
I copied a script from this site http://javascript.internet.com/calculators/ad-calculator.html and was able to modify it to handle 4 sets of variables. Now I want to total the results of these calculations but haven't been able to isolate the answer of each. Here is how the script is today. http://www.devodd.com/CompToday.htm Any help would be very much appreciated.
Thank You!
Khalid Ali
07-08-2003, 01:28 PM
add these variables in the very beginningodf the your javascript code in the head section
var t1=0,t2=0,t3=0,t4=0,total=0;
then locate this function
a_plus_d()
and replace the whole function witht he code below
function a_plus_d() {
var total=parseFloat(t1)+parseFloat(t2)+parseFloat(t3)+parseFloat(t4)
document.calculator.total.value=total
}
finally in the totals buttin(+)
remove "e" from prams so that your onclick event of the total button look like this.
onClick="a_plus_d()"