Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a final Total ?

Status
Not open for further replies.

data1

Programmer
Aug 19, 2003
25
0
0
NZ
<SCRIPT language=&quot;JavaScript&quot;>//start of calculation function for Brazillian
function calculate(){
var f = document.myForm;
var first = f.brazillianBeans.value;
var second = f.brazillianFilter.value;
var third = f.brazillianPlunger.value;
var fourth = f.brazillianEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5.value = five;
f.totalPrice1.value = (five * 18.95) .toFixed(2);
}//end of calculation function for Brazillian



//start of calculation function for bluemountain
function calculate2(){
var f = document.myForm;
var first = f.bluemountainBeans.value;
var second = f.bluemountainFilter.value;
var third = f.bluemountainPlunger.value;
var fourth = f.bluemountainEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5a.value = five;
f.totalPrice2.value = (five * 18.95) .toFixed(2);
}//end of calculation function for bluemountain


//start of calculation function for Columbian
function calculate3(){
var f = document.myForm;
var first = f.columbianBeans.value;
var second = f.columbianFilter.value;
var third = f.columbianPlunger.value;
var fourth = f.columbianEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5b.value = five;
f.totalPrice3.value = (five * 18.95) .toFixed(2);
}//end of calculation function for columbian


//start of calculation function for Costa Rica
function calculate4(){
var f = document.myForm;
var first = f.costaricaBeans.value;
var second = f.costaricaFilter.value;
var third = f.costaricaPlunger.value;
var fourth = f.costaricaEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5c.value = five;
f.totalPrice4.value = (five * 18.95) .toFixed(2);
}//end of calculation function for Costa Rica



//start of calculation function for Espresso
function calculate5(){
var f = document.myForm;
var first = f.espressoBeans.value;
var second = f.espressoFilter.value;
var third = f.espressoPlunger.value;
var fourth = f.espressoEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5d.value = five;
f.totalPrice5.value = (five * 18.95) .toFixed(2);
}//end of calculation function for Espresso



//start of calculation function for Kenya
function calculate6(){
var f = document.myForm;
var first = f.kenyaBeans.value;
var second = f.kenyaFilter.value;
var third = f.kenyaPlunger.value;
var fourth = f.kenyaEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5e.value = five;
f.totalPrice6.value = (five * 18.95) .toFixed(2);
}//end of calculation function for Kenya



//start of calculation function for New Guinea
function calculate7(){
var f = document.myForm;
var first = f.newguineaBeans.value;
var second = f.newguineaFilter.value;
var third = f.newguineaPlunger.value;
var fourth = f.newguineaEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5f.value = five;
f.totalPrice7.value = (five * 18.95) .toFixed(2);
}//end of calculation function for New Guinea



//start of calculation function for Decaffeinated
function calculate8(){
var f = document.myForm;
var first = f.decaffeinatedBeans.value;
var second = f.decaffeinatedFilter.value;
var third = f.decaffeinatedPlunger.value;
var fourth = f.decaffeinatedEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5g.value = five;
f.totalPrice8.value = (five * 22.95) .toFixed(2);
}//end of calculation function for Decaffeinated




//start of calculation function for Organic
function calculate9(){
var f = document.myForm;
var first = f.organicBeans.value;
var second = f.organicFilter.value;
var third = f.organicPlunger.value;
var fourth = f.organicEspresso.value;
var five = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth);
f.t5h.value = five;
f.totalPrice9.value = (five * 22.95) .toFixed(2);
}//end of calculation function for Organic

//start of calculation function for Maxwell House
function calculate10(){
var f = document.myForm;
var one = f.maxwellHouse.value;
f.totalPrice10.value = (one * 19.95) .toFixed(2);
}//end of calculation function for Maxwell House

//start of calculation function for Williams Premium Blended Tea
function calculate11(){
var f = document.myForm;
var one = f.williamspremiumblendedTea.value;
f.totalPrice11.value = (one * 2.95) .toFixed(2);
}//end of calculation function for Williams Premium Blended Tea


//start of calculation function for Milo
function calculate12(){
var f = document.myForm;
var one = f.miLo.value;
f.totalPrice12.value = (one * 11.65) .toFixed(2);
}//end of calculation function for Milo




//start of Total calculation
function calculateTotal(){
var f = document.myForm;
var first = f.totalPrice1.value;
var second = f.totalPrice2.value;
var third = f.totalPrice3.value;
var fourth = f.totalPrice4.value
var fifth = f.totalPrice5.value;
var sixth = f.totalPrice6.value;
var seventh = f.totalPrice7.value;
var eighth = f.totalPrice8.value;
var ninth = f.totalPrice9.value
var tenth = f.totalPrice10.value;
var eleventh = f.totalPrice11.value
var twelth = f.totalPrice12.value;

var thirteen = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth) + parseFloat(fifth) + parseFloat(sixth) + parseFloat(seventh) + parseFloat(eighth) + parseFloat(ninth) + parseFloat(tenth) + parseFloat(eleventh) + parseFloat(twelth);
f.totalValue.value = thirteen;
}//end of Total calculation
----------------------------------------------------------
//I would like to add all functions above to get a final
out put below but keep getting a NaN//

<td>$=</td>
<td><INPUT type=&quot;text&quot; name=&quot;totalValue&quot; onFocus=&quot;document.myForm.totalValue.blur()&quot; readonly=&quot;true&quot;value=&quot;0&quot;size=&quot;5&quot;></td>
<TD>

<INPUT type=&quot;button&quot; value=&quot;calculateTotal&quot; onMouseover=&quot;MM_validateForm('t5','','NisNum','totalValue','','NisNum');return calculateTotal();return document.MM_returnValue&quot;>
</TD>
 
Do you have a link where we can test this?

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]
 
var thirteen = parseFloat(first) + parseFloat(second) + parseFloat(third) + parseFloat(fourth) + parseFloat(fifth) + parseFloat(sixth) + parseFloat(seventh) + parseFloat(eighth) + parseFloat(ninth) + parseFloat(tenth) + parseFloat(eleventh) + parseFloat(twelth);

ENTER DEBUG MODE:
try doing each of the above parseFloat()s individually an see which is giving you Not-A-Number.

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top