Need Help

Discussion in 'JavaScript' started by valleyjim, Sep 18, 2005.

  1. #1
    New at javascript whats wrong with the following script

    <SCRIPT LANGUAGE="JavaScript"> // MY FORECAST
    var T ='Falling' //'~~WEBBARTRND~~' // TREND
    var P ='29.75' //'~~WBNBAROMTR~~' // PRESSURE
    var D ='87' //'~~WBNWINDGSD~~' //WIND DIRECTION DEGREES
    var A
    if (D >= '214' && D <='326' && P >='30.10' && P <= '30.20' && T == 'Steady');
    A = "Fair with little temp. change for next 2 days"
    if (D >= '214' && D <='326' && P >='30.10' && P <= '30.20' && T == 'Rising');
    A = "Fair followed by rain in 2 days"
    if (D >= '214' && D <='326' && P >='30.20' && T == 'Steady');
    A = "Continued fair with little temp. change"
    if (D >= '214' && D <='326' && P>= '30.20' && T == 'Falling');
    A = "Slowly rising temp; fair for 2 days"
    if (D >= '124' && D <='191' && P >='30.10' && P <='30.20' && T == 'Falling');
    A = "Rain within 24 hours"
    if (D >= '124' && D <='191' && P >='30.20' && T == 'Falling');
    A = "Wind rising in force; rain in 12 - 24 hours"
    if (D >= '34' && D <='146' && P >='30.10' && P <='30.20' && T == 'Falling');
    A = "Rain in 12 - 18 hours "
    if (D >= '34' && D <='101' && P >='30.10' && T == 'Falling');
    A = "Rain (snow) within 24 hours in winter "
    if (D >= '34' && D <='101' && P <='30.10' && T == 'Falling');
    A = "Rain (snow), wind "
    if (D >= '34' && D <='146' && P <='30.00' && T == 'Falling');
    A = "Steady rain for 1 - 2 days"
    if (D >= '169' && D <='236' && P <='30.00' && T == 'Rising');
    A = "Clearing within a few hours then fair"
    if (D >= '79' && D <='191' && P <='29.80' && T == 'Falling');
    A = "Severe storm imminent, clearing in 24 hrs"
    if (D >= '0' || D <='101' && P <='29.80' && T == 'Falling'); // Set for this
    A = "Severe northeast gale, rain (snow)"
    if (D >= '0' && D <='281' && P <='29.80' && T == 'Rising');
    A = "Clearing and colder"
    if (D >= '281' && D <='360' && P <='29.80' && T == 'Rising');
    A = "Clearing and colder"
    if (D >= '102' && D <='123' && P <='30.03' && T == 'Steady');
    A = "Clearing and colder"
    document.write(A);

    </SCRIPT>
     
    valleyjim, Sep 18, 2005 IP
  2. Arnica

    Arnica Peon

    Messages:
    320
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to remove the semi-colons from your 'if' clause. They should be at the end of your 'A=bla bla' lines.

    You're also comparing strings which won't give you the result you were expecting.

    Use 'else if ...' so that the processing stops when a match is found.
     
    Arnica, Sep 18, 2005 IP
  3. KingSEO

    KingSEO Peon

    Messages:
    295
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #3
    KingSEO, Sep 18, 2005 IP
  4. valleyjim

    valleyjim Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the help
     
    valleyjim, Sep 18, 2005 IP