Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
And now it does nothing
Message
De
04/04/2013 03:27:56
 
 
À
03/04/2013 14:38:57
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01569918
Message ID:
01570029
Vues:
40
>I still got (get) nothing.
>
>It appears to be an issue with the 'if' statement
>
>If I leave out the if/else and put the alert first
>
>alert('Please select a recipe');
>location.href='go.hcn?hcn2~recipe~'+topiclist.options[topiclist.selectedIndex].value;
>
>
>I get the alert, then it goes to the selected recipe (and still error/logs on the "Select topic")
>
>I've tried changing the if around
>
>function SCDropDown(topiclist)
>  {
>    if (topiclist.selectedIndex == 0)
>     {
>      alert('Please select a recipe');
>      }
>    else {
>      location.href='go.hcn?hcn2~recipe~'+topiclist.options[topiclist.selectedIndex].value;
>       }
>  }
>
I copied the exact code above and it works for me (except, of course, I get a 404 on the URL)

Check your code in a debugger. If you haven't used one yet I'd suggest Chrome. Get the page up in the browser and hit Ctrl-Shift-I.
The Console tab will show any errors; the Sources tab allows you to select the source, set breakpoints and inspect values.


>I've even tried
>
>if (1==1)
>
>
>and still nothing.
>
>This is giving me a huge headache 'cuz it shouldn't be this dang difficult to put if logic into freakin' Javascript
>
>>>If this is Javascript, If should be lowercase and the condition within parentheses I believe. If there is no error, make sure the browser is set to show the Javascript errors.
>>
>>Yep. The 'If' is a problem. This should work:
function SCDropDown(topiclist)
>>        {
>>            if (topiclist.selectedIndex > 0)
>>            {
>>                location.href='go.hcn?hcn2~recipe~'+topiclist.options[topiclist.selectedIndex].value;
>>            }
>>        else {
>>                alert('Please select a recipe');
>>            }
>>        }
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform