[thelist] does JavaScript have an equivalent to IsDefined()?

Sarah poohbear at designshift.com
Tue Sep 23 09:26:40 CDT 2003


> > This is server-side. When I do Response.Write(Request.QueryString('id')),
>I
> > get undefined, but if I try to compare to undefined, i.e...
> >    if (Request.QueryString('id') != undefined) { }
> > ...the code executes (incorrectly), and an error is thrown because the
> > query that follows craps out on the undefined value. *Very* perplexing!
> >
> > (BTW, I've tried comparing to both undefined and 'undefined', same results
> > with each - which is correct?)
>
>Sarah,
>
>This should work:
>
>if ( Request.QueryString('id').Item == 'undefined' )
>{
>     Response.Write( 'id is not present in query string );
>}
>else
>{
>     Response.Write( 'id is present in query string );
>}
>
>The key is to use the Item property explicitly
>...

Ahhh... Finally :) It's not exactly what you suggested, Glenn, but this worked:
if (Request.QueryString('id').Item != undefined)

Thanks, Glenn, and everyone else who made a suggestion.

Sarah

BTW, Jeff, you are correct, I should have said I am using JScript :)



More information about the thelist mailing list