[thelist] JS Boolean Object...

Jeff Howden jeff at jeffhowden.com
Thu Dec 4 16:24:31 CST 2003


walter,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: jsWalter
>
> bolValue = someFunc ( someVar );
>
> if ( bolValue )  // true
>     // do something here
> else
>     alert ( bolValue.err );
>
>
> As you can see, I need to define a var as a Boolean and
> if I have a problem, add a message element to the
> Object.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

in your case, "if(bolValue)" becomes a check for existence, which will
return true.  if it's an object and you're adding a property if there's an
error, then try this instead:

if(bolValue && !bolValue.err) // true
  // do something here
else
  alert(bolValue.err);

.jeff

------------------------------------------------------
Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/



More information about the thelist mailing list