if else bug and calculate interest funtion help me plz

This is a discussion on "if else bug and calculate interest funtion help me plz" within the JavaScript Forum section. This forum, and the thread "if else bug and calculate interest funtion help me plz are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 26th, 2005, 05:53
New Member
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
if else bug and calculate interest funtion help me plz

Hi guys im trying to work out the interest if the user entered a price and a quantity then depending on what radio button they select it then adds interest onto the total cost.

I tried using if else statements as well and it would only calculate the cost and would not attemp to try the other if statements even though i selected the different radio buttons. There is a few bugs could someone help me out please

cash it add 5$
credit adds 1.5 % onto the total cost
cheque adds 2 dollars

where have i gone wrong

thanks

For example

cost qty
6000 * 1 /100 *1.5 interest how would i add that result onto the
running total

Code: Select all
function caculateOrder(form)
{

  var total = form.total.value;
  var qty = form.qty.value;
  var price = form.price.value;
  var radio1 = form.cash.value;
  var radio2 = form.credit.value;
  var radio3 = form.cheque.value;
  var interest;
  
  
  if(qty !="" && price !="")
  {
  
    alert("Warning calculating the total cost!");
  
    if(document.orderform.rad[0])
    {
       form.total.value = ((qty * price)) + 5;
       document.write("You have chosen cash" + form.total.value);
    }
    
   
    
    if(document.orderform.rad[1])
    {
      
      
      
      form.total.value = ((price * qty));
      // calculates added interest of 1.5 %  
      form.total.value = ((price * qty / 100) * 1.5) ;
      // need to add the total of price and qty and the interest to get 
         total cost
      
      document.write("You have chosen credit" + form.total.value);
    
    }
    
    
    if (document.orderform.rad[2])
    {
    
      form.total.value = qty ((qty * price)) + 2;
      document.write("You have chosen cash" + form.total.value);
      
    }
    
    
    
  
  }

}
Reply With Quote

  #2 (permalink)  
Old Sep 26th, 2005, 07:31
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
To start I would change this line

form.total.value = ((price * qty / 100) * 1.5)
to
form.total.value *= 1.5 / 100

and

form.total.value = qty ((qty * price)) + 2;
to
form.total.value = (qty * price) + 2;

Is it picking the right if statement (payment method)? Because boolean checking a radio value won't always work.
Reply With Quote
Reply

Tags
else, bug, calculate, interest, funtion, help, plz

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Article of interest: PHP in the Enterprise (Take 2) estherschindler PHP Forum 2 Mar 21st, 2008 22:50
Fatal error: call to a member function funtion() on a non-object timcallagy Databases 2 Mar 4th, 2007 21:55
Calculate item quantity plus shipping SteveJP JavaScript Forum 15 Oct 3rd, 2006 21:33
VB Code to Calculate Query Results Imara96 Databases 1 Jun 20th, 2006 22:20


All times are GMT. The time now is 10:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43