[thelist] JS: compound ternary

Tom Dell'Aringa pixelmech at yahoo.com
Fri Jan 30 15:29:20 CST 2004


Hey JS people,

I'm trying to build a compound ternary statement and I keep falling
flat on my face. I know I have something mixed up, I keep getting a
syntax error. There's a bracket set missing or something. Here's the
statement:

var restrict = (document.getElementById) ?
document.getElementById(oName) : (document.all) ? document.all[oName]
: return;

The first condition should check for get by ID, next doc.all. If its
not either it should return, otherwise is should set the correct
object reference. I know you can do this I've seen it many times, I
just can't find an example when I need it (as usual).

TIA

Tom

P.S - I'm aware there are other ways to go about doing it - I just
want to do it this way. :)

=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: JavaScript Author / Every Friday!
http://www.thywordistruth.net/ :: Eternal Life

[Those who say that I am finished, and am through, will have to run over my dead body to beat me...]


More information about the thelist mailing list