1. Novice Webmaster Join Date
Feb 2003
Location
Bandar Tasik Selatan, Malaysia
Posts
25
Rep Power
0

syntax

Can anyone help me with my syntax?

// if parcel.
if (tmpWeight <= 1)
{
tmpTotalPrice = '20';
break;
}
else
{
tmpWeight2 = tmpWeight - 1;
if tmpWeight2 <= 0.5;
{
tmpTotalPrice = 25;
break;
}
else
{
tmpTotalPrice = 20 + ((parseInt(tmpWeight2/0.5)) * 5);
break;
}

2. What's the purpose of the script? What you are trying to achieve?

3. Novice Webmaster Join Date
Feb 2003
Location
Bandar Tasik Selatan, Malaysia
Posts
25
Rep Power
0
It's kinda rate calculation. My company is a courier service company. I want to develop a online rate calculator. User first click where to sent to (destination), click type of consignment (parcel or document) and then its weight. When he is done, he click the button to calculate.

I have done the document part while still figuring out the parcel part. Document one has easier logic.

if weight <= 0.5 (kg) then
price = RM6

But for parcel one is much tricker,

if weight <= 1 kg then
price = RM20

and the most difficult one is for 10 kg and above, every 0.5 kg add RM3.

That's it. Thanks.

4. For parcel. I did a quick one, may have bugs, or maybe calculation not correct. If you want, take a look and let me know if correct or not PHP Code:
``` <script language=javascript> function gee() {     var w = 2;     var price = 0;     if(w <= 1)         price = 20;     else if(w > 10){         var w1 = 1;         var w2 = 9;         var w3 = w-10;         price  = w1 * 20;         price += w2 * 2 * 5;         price += w3 * 2 * 3;     }else {         var w1 = 1;         var w2 = w-1;         price  = w1 * 20;         price += w2 * 2 * 5;     }     alert(price); } </script>  <body onload="gee();">  ```

5. Novice Webmaster Join Date
Feb 2003
Location
Bandar Tasik Selatan, Malaysia
Posts
25
Rep Power
0
kpyew, I don't actually know how to test it because I don't understand how it works but the link to my rate table is in http://www.citylinkexpress.com/singa..._east_asia.asp

6. Simple. The script is only for Parcel. Simply paste the codes in a blank .htm file and open it up in your broser (Internet Explorer).

Change the var w = 2, value which stores the weight. Example var w = 30;.

That's it.