Results 1 to 6 of 6

Thread: syntax

  1. #1
    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. #2
    Join Date
    Jul 2001
    Location
    KL, Malaysia
    Posts
    277
    Rep Power
    223
    What's the purpose of the script? What you are trying to achieve?

  3. #3
    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

    and every additional 0.1 kg add RM1

    But for parcel one is much tricker,

    if weight <= 1 kg then
    price = RM20

    and every additional 0.5 kg add RM5

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

    That's it. Thanks.

  4. #4
    Join Date
    Jul 2001
    Location
    KL, Malaysia
    Posts
    277
    Rep Power
    223
    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 
    2;
        var 
    price 0;

        if(
    <= 1)
            
    price 20;
        else if(
    10){
            var 
    w1 1;
            var 
    w2 9;
            var 
    w3 w-10;

            
    price  w1 20;
            
    price += w2 5;
            
    price += w3 3;
        }else {
            var 
    w1 1;
            var 
    w2 w-1;

            
    price  w1 20;
            
    price += w2 5;
        }

        
    alert(price);
    }
    </script> 

    <body onload="gee();"> 

  5. #5
    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. #6
    Join Date
    Jul 2001
    Location
    KL, Malaysia
    Posts
    277
    Rep Power
    223
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. error in your SQL syntax
    By el_idura in forum Website Programming
    Replies: 6
    Last Post: 13-09-2005, 09:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112