Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: CHECK FOR NULL VALUE


Message #1 by "Pallone, Claudio [KMR-SPC]" <Claudio.Pallone@k...> on Wed, 16 Oct 2002 14:55:20 +0100
Hi,

Two weeks ago Robert showed me how to create a function that would 
highlight the <td>s of a table according to some criteria. This works 
wonderfully well.

However, since I am using frames, I have to make sure that all the 
frames are loaded. If the user clicks on the highlight button before the 
bottom frame is loaded then I get an alert saying that
the bottom frame is null.

I have tried to use an "if" statement to check if the frame is null but 
it is not working.

Any ideas why this "if" statement is not working?

Cheers,

var bColoredTDs =3D false;
function HighlightIndexTD()
{
if(parent.frames[1].rightBottom.document.getElementsByTagName("table") 
!=3D null)
{
	var arrTables =3D 
parent.frames[1].rightBottom.document.getElementsByTagName("table");
	for(var i=3D0; i<arrTables.length; i++)
	{
		if(i > 0)
		{
			var arrAllCurrentTableRows =3D 
arrTables[i].getElementsByTagName("tr");
			for(var j=3D0; j<arrAllCurrentTableRows.length; j++)
			{
				var oAllCells =3D 
arrAllCurrentTableRows[j].getElementsByTagName("td");
				with(oAllCells[oAllCells.length - 1])
				{
					var intValue =3D parseInt(innerHTML, 10);
					if(!bColoredTDs && (intValue < 80 || intValue > 120))
					{
						style.color =3D "white";
						style.backgroundColor =3D (intValue < 80)? "blue" : "red";
					}
					else
					{
						style.color =3D "black";
						style.backgroundColor =3D "white";
					}
				}
			}
		}
	}
	bColoredTDs =3D (bColoredTDs)? false : true;
else
{
alert("Choose a Report");
}

}



BMRB International
http://www.bmrb.co.uk +44 (0)20 8566 5000
____________________________________________________________
This message (and any attachment) is intended only for the recipient and 
may contain confidential and/or privileged material. If you have 
received this in error, please contact the sender and delete this 
message immediately. Disclosure, copying or other action taken in 
respect of this email or in reliance on it is prohibited. BMRB 
International Limited accepts no liability in relation to any personal 
emails, or content of any email which does not directly relate to our 
business.

  Return to Index