1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

javascript code for delivery charge

Discussion in 'JavaScript and AJAX' started by Capparaceae, Jan 6, 2009.

  1. Capparaceae

    Capparaceae New Member

    Joined:
    Jan 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    If user inputs distance is within 3 miles, there's no charge.
    If user lives more than 3 miles but not more than 12 they pay.
    No delivery over 12 miles.

    I'm struggling with making the code do more than 3 but less than 12 miles.
    Could anyone give me a bit of a clue please?
    Below is the partially coded page.
    <SCRIPT LANGUAGE = "JavaScript"> // A delivery charge program for the Company var distance;
    var extraDistance; // A variable you will need to use
    distance = window.prompt('Please enter the distance in miles', ''); distance = parseFloat(distance); // Insert your code here </SCRIPT>
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    Moved to Javascript forum for better response.
    Code:
    if( valueEnter > 3 && valueEnter < 12 )
    {
        Do something
    }
     
  3. Capparaceae

    Capparaceae New Member

    Joined:
    Jan 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Once again I have reason to Thank You so very much, Shabbir. No wonder I couldn't get it right, as I've never done the variable IF !! Am on huge learning curve
     

Share This Page