[Javascript] I can test for undefined...using typeof or === or == please help

Cutter Bl cutterbl at hotmail.com
Mon Aug 13 07:31:39 CDT 2001


I would get the "undefined" on dropdown selection within NN (IE was fine). 
On the advice of a fellow designer I went this way...

thisForm.FIELDNAME.options[thisForm.FIELDNAME.selectedIndex].value

and it then worked fine on both platforms.

Cutter
http://www.falcon-knives.com

***************************************
From: "TomMallard" <mallard at serv.net>
Reply-To: javascript at LaTech.edu
To: <javascript at LaTech.edu>
Subject: Re: [Javascript] I can test for undefined...using typeof or === or 
== please help
Date: Sat, 11 Aug 2001 07:26:46 -0700

This syntax should work....

if (typeof(mydropdown.options[0]) == 'undefined'){...do something...}

If mydropdown.options[0] isn't an object you can't get a property. You may
be getting this error if the code is parsed before the select box is done
being written (timing error). Place the code after the select box it
references or fire it with the onload event from the body tag if that's what
is happening.

tom mallard
seattle
----- Original Message -----
From: "Scott.Wiseman" <swiseman at remax-cahi.com>
To: <javascript at LaTech.edu>
Sent: Friday, August 10, 2001 6:20 PM
Subject: [Javascript] I can test for undefined...using typeof or === or ==
please help


 > non of these if statements catch the undefined
 >
 > but the alert reports 0 undefined.
 > so what's up.... is there a type???
 >
 >
 > here is the code:
 >
 >
 >  alert("0 "+mydropdown.options[0].value);
 >    if(typeof mydropdown.options[0].value == undefined)
 >    {
 >     alert("found 1")
 >     myvalue1 = NULL;
 >    }
 >    if(typeof mydropdown.options[0].value == undefined)
 >    {
 >     alert("found x 1")
 >    }
 >    if(typeof mydropdown.options[0].value === undefined)
 >    {
 >     alert("found x 2")
 >    }
 >    if(mydropdown.options[0].value == undefined)
 >    {
 >     alert("found x 3")
 >    }
 >
 >    if(typeof mydropdown.options[0].value != undefined ||
 > mydropdown.options[0].value != "unde" )
 >    {
 >     myvalue1 = mydropdown.options[0].value;
 >    }
 >

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




More information about the Javascript mailing list