I have this javscript that I wrote, and I want the “else” event to happen when bgimage does not equal 7. I have looked into this issue and am unclear about how to check if the variable is null or not defined. Currently, when bgimage does not equal 7, the Firebug just says “bgimage is not defined.”
Thanks for teaching me how to do this in advance.
if (bgimage == 7)
{
document.writeln("\n<img src='/v/vspfiles/templates/donnell/images/Company/services_bg.jpg' id='bg' />");
}
else
{
showImage();
}
If
bgimagehas not been declared withvarin the current or higher scope (or assigned a value as a global variable withoutvar) when you use it in anifstatement you will get that error. You can test for that as follows:Or test in one line: