Problems with a delivery charge program.

Discussion in 'JavaScript' started by viper1288, May 13, 2007.

  1. #1
    It's just a work in progress at the moment, but I'd appreciate some help, again.

    I'm writing a program for a delivery service where there are following conditions.

    For orders worth less than £25 the delivery charge is £3.00.
    Orders worth at least £25 but less than £100 are delivered free.
    Orders worth £100 or more are delivered free and in addition the
    customer receives a free gift. I prompt the user to enter the order value, and tell him/her which band he comes under.

    This is what I have so far, and it doesn't seem to be it, evidently.

    
    <html> 
    <body> 
    <script type='text/javascript'> 
    // A delivery charge program 
    var ordervalue; // how much the order is worth ordervalue = window.prompt ('How much is the order worth in Pounds Sterling?','');  
    str='The value of your order is £' + ordervalue; 
    if (ordervalue <= 25) 
    str='Your delivery will cost £3 as your order value is £' + ordervalue'; 
    if (ordervalue > 25 &&  ordervalue < 100)
    {  str='Your delivery is free as your order value is £' + ordervalue';  
    }else 
    str='You will receive a free gift and delivery is free as your order value is £' + ordervalue; 
    alert(str); // to output a result to see it is works! 
    </script> 
    </body> </html>
    
    Code (markup):
    I'd love some help, please
     
    viper1288, May 13, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    I wouldn't do that, its wide open to hackery, I would have the cost of the order determined by a server side language and passed to the next page where they can choose a free gift if necessary and or review thier price + postage ...

    If you post the order form, I'll do an example sometime .....
     
    krakjoe, May 14, 2007 IP
  3. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #3
    use server side check as Krakjoe said in his post.
     
    gibex, May 14, 2007 IP