Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
And now it does nothing
Message
De
04/04/2013 12:53:22
 
 
À
04/04/2013 12:01:20
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01569918
Message ID:
01570101
Vues:
37
>>Finally found the issue, and yes - I feel like an idiot.
>>
>>Apparently, while trying various things I inadvertently capitalized the 'I' in 'If' and no one (including me) that was looking at it caught it for quite a while.
>
>Hmm. Michel pointed out the capitalization problem quite early on in this thread - and your posted sample code had it right....

Yes, he did...and Yes, I know - it was in the re-typing of the line of code that the 'shift-I' happened. did I mention I felt like an idiot when we caught it?



>
>>Once I un-capitalized it, it worked exactly as it should. javascript - case insensitive, 'til it's not.
>>
>>
>>
>>>>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');
>>>>>            }
>>>>>        }
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform