all groups > dotnet jscript > october 2005 >
You're in the

dotnet jscript

group:

Javascript If/else conditions


Javascript If/else conditions Cleako
10/21/2005 12:25:03 PM
dotnet jscript:
I may just be having one of those days but I cant think of a good way to do
something like this - if(item1.checked || item2.checked || item3.checked ...).

If the 1st two are true then it works, if it is the 3rd one on then it
doesnt. I have 5 controls I need to check for a checkbox in so that I can
control what type of file a user is choosing for processing. What do I do if
I have more than 2 items to compare against? In .NET this isnt an issue so I
Re: Javascript If/else conditions Bruce Barker
10/21/2005 4:50:06 PM
your syntax is correct. most likely one of the items is null, so the script
is dieing when you ref the checked property.

if the item may or may not exist then:

if ((item1 && item1.checked) || ((item2 && item2.checked) )


[quoted text, click to view]

Re: Javascript If/else conditions Cleako
10/22/2005 12:54:01 PM
So the (item1 && item1.checked) is only checked if the item1 has been
populated? I thought that the .checked would either be true or false, what
would make it return a null value?

Cleako

[quoted text, click to view]
AddThis Social Bookmark Button