432,275 Members | 936 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

# Need Help with Calculator Java Script

 P: n/a So I am trying to get this Calculator to work. It needs to take in a vaule, and select a shipping Everythin works great except the shipping part. I need it to take the shipping value and add it to the "Downpayment" and also the "Total amount paid" Example: item cost \$20.00 , \$8.50 shipped selected, Payment 1 = 12 + 8.50 so \$20.50 Payments 2-5 = \$2.00 Final Payment = \$28.50 can Anyone help me? Expand|Select|Wrap|Line Numbers   Ground - \$8.50 3-Day - \$10.50 2-Day - \$14.50 Overnight - \$24.00

//calculate function function calc(){   //variables var price = document.converter.price.value var downpaymentdisplay = Math.round(price * .60) var payment2display = Math.round(price * .10) var payment3display = Math.round(price * .10) var payment4display = Math.round(price * .10) var payment5display = Math.round(price * .10)   var totaldisplay = Math.round(downpaymentdisplay + payment2display + payment3display + payment4display + payment5display)   //write in text box document.converter.downpayment.value=downpaymentdisplay document.converter.payment2.value=payment2display document.converter.payment3.value=payment3display document.converter.payment4.value=payment4display document.converter.payment5.value=payment5display document.converter.total.value=totaldisplay   } Thanks Yoni Jun 27 '08 #1

#### ✓ answered by suhasdhoke@gmail.com

On Jun 24, 11:08 pm, Yonih <Yoni.Hir...@gmail.comwrote:

You missed to add the selected shipping option's value to the
downpaymentdisplay var.
Try This...
Expand|Select|Wrap|Line Numbers
1. var downpaymentdisplay = Math.round(price * .60)
Expand|Select|Wrap|Line Numbers
1. var downpaymentdisplay = Math.round(price * .60)  +
2. eval(document.converter.shippingOptions.value)
Expand|Select|Wrap|Line Numbers
1. var totaldisplay = Math.round(downpaymentdisplay + payment2display +
2. payment3display + payment4display + payment5display)
Expand|Select|Wrap|Line Numbers
1. var totaldisplay = (downpaymentdisplay + payment2display +
2. payment3display + payment4display + payment5display)
Cheers!!

4 Replies

 P: n/a On Jun 24, 11:08 pm, Yonih

 P: n/a Thank you so much, It works Great Yoni Jun 27 '08 #3

 P: n/a SO Hey I have anouther option to add to my calculator if anyone is interested in the challange and helping me out a lot. Here is the updated Calcualtor thanks to suhasdhoke. These are the changes I need as you can see I have the date for the first displaying field but I need the rest to be date +30 days, +60,+90 and, +120. Anychance someone knows how to do it? Thanks Expand|Select|Wrap|Line Numbers
Select Shipping Ground - Free 3-Day - \$10.50 2-Day - \$14.50 Overnight - \$24.00
Enter Price of Item   // Get today's current date. var now = new Date(); // Array list of months. var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December'); // Calculate the number of the current day in the week. var date = ((now.getDate()<10) ? "0" : "")+ now.getDate(); // Calculate four digit year. function fourdigits(number)   { return (number < 1000) ? number + 1900 : number; } // Join it all together today =  months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())) ;

Total + 30 Days
Today + 60 Days
Today + 90 Days
Today + 120 Days

Total Amount Paid

//calculate function function calc(){   //variables var price = document.converter.price.value var downpaymentdisplay = Math.round(price * .60)  + eval(document.converter.shippingOptions.value) var payment2display = Math.round(price * .10) var payment3display = Math.round(price * .10) var payment4display = Math.round(price * .10) var payment5display = Math.round(price * .10)   var totaldisplay = Math.round(downpaymentdisplay + payment2display + payment3display + payment4display + payment5display) var totaldisplay = (downpaymentdisplay + payment2display + payment3display + payment4display + payment5display)   //write in text box document.converter.downpayment.value=downpaymentdisplay document.converter.payment2.value=payment2display document.converter.payment3.value=payment3display document.converter.payment4.value=payment4display document.converter.payment5.value=payment5display document.converter.total.value=totaldisplay   } Jun 27 '08 #4

 P: n/a Never Mind I was able to work it out. Thanks Yoni Jun 27 '08 #5

### This discussion thread is closed

Replies have been disabled for this discussion.