473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Javascript

3
I am new using javascript for the pdf and I have the following code and the calculation doesn't. What I am trying to do is if the person check USA it will display the correct value into the field otherwise if other than USA it will do the second case.
Any help will be appreciated and thank you in advance.

Here is what I have:

Expand|Select|Wrap|Line Numbers
  1. var AmtShipping = this.getField("Cost").value;
  2. var Country = this.getField("Country").value;
  3.  
  4. if( AmtShipping == 0)
  5. event.value = '';
  6. if(( AmtShipping == 7)&&(Country ==USA))
  7.    event.value = 9.00;
  8. if((AmtShipping ==9)&&( Country ==USA))
  9.         event.value = 4.50;
  10. if((AmtShipping <=50)&&( Country ==USA))
  11.         event.value = 9.00;
  12. if((AmtShipping <=100)&&( Country ==USA))
  13.         event.value = 12.00;
  14. if((AmtShipping <=150)&&( Country ==USA))
  15.         event.value = 12.00;
  16. if( AmtShipping >= 151)
  17. {
  18.      event.value = 25.00};
  19. if((AmtShipping <=50)&&( Country !=USA))
  20. event.value = 18.00;
  21. if((AmtShipping <=100)&&( Country !=USA))
  22. event.value = 22.00;
  23. if((AmtShipping <=150)&&( Country !=USA))
  24. event.value = 27.00;
  25. if( AmtShipping >= 151)
  26. {
  27.      event.value = 32.00};

Thank you in advance
Aug 4 '10 #1
2 936
Dormilich
8,658 Expert Mod 8TB
from the language point-of-view, USA should be quoted, using filling zeroes is pointless, JS has exactly 1 number type (IEEE 754 float).

you *may* run into trouble using event as variable name.

And I’d definitely split the conditions, so that you don’t have to check 2 conditions at once.
Expand|Select|Wrap|Line Numbers
  1. // needs to be put in a function
  2. if ("USA" == Country) {
  3.     if (AmtShipping <= 50) {
  4.         return 9;
  5.     }
  6.     if (AmtShipping <= 100) {
  7.         return 12;
  8.     }
  9.     // etc.
  10. }
  11. else {
  12.     // …
  13. }
Aug 4 '10 #2
xiou
3
Thank you so much for your help.
Aug 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.