Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: RE: javascript_howto digest: October 02, 2002


Message #1 by "Pallone, Claudio [KMR-SPC]" <Claudio.Pallone@k...> on Thu, 3 Oct 2002 10:30:32 +0100
Hi Robert,

WOW!! Many thanks for your help and sample code. This has a great 
incentive for me to learn more about Javascript. Some of these concepts 
you presented here are still not entirely clear to me. So could you 
please elaborate a bit more on these questions:

1 - You are using the window.onload =3D function (). In my case I will 
have to use a <span> on a <a> tag (I will have a link at the navigation 
bar at the top of the page. This is in the topFrame but my tables are in 
the mainFrame. So I think I will have to go to the parent frame first?? 
IS that right?) Is it ok if I use the onlcik event on the <span> ?

2- You said: "If you're only targetting IE, then exhange innerHTML to 
innerText"

Please could you explain the difference to me?? I am targetting IE and 
Netscape.

3 - When my tables are generated they will have IDs like table1, table2 
...This does not affect the use of 
document.getElementsByTagName("table"); does it??

Agai many thanks for your time and effort.

Cheers,

Claudio

>Subject: SV: TD HIGHLIGHT
>From: "Robert Nyman" <robert.nyman@c...>
>Date: Wed, 2 Oct 2002 15:51:14 +0200
>X-Message-Number: 2

>Hi Claudio,

>as always, it depends on what browsers you are targetting.
>But this will work for you in IE5+ and Netscape 6+:

>window.onload =3D3D function (){
	var arrTables =3D3D document.getElementsByTagName("table");
	for(var i=3D3D0; i<arrTables.length; i++){
		var arrAllCurrentTableCells =3D3D
arrTables[i].getElementsByTagName("td");
		for(var j=3D3D0; j<arrAllCurrentTableCells.length; j++){
			var oTD =3D3D arrAllCurrentTableCells[j];
			var intValue =3D3D parseInt(oTD.innerHTML, 10); //
If you're only targetting IE, then exhange innerHTML to innerText
			if(intValue < 50 || intValue > 100){
				oTD.style.color =3D3D "white";
				oTD.style.backgroundColor =3D3D (intValue <
50)? "blue" : "red";
			}
		}
	}
}


<table>
	<tr>
		<td>103</td>
		<td>49</td>
		<td>76</td>
	</tr>
	<tr>
		<td>49</td>
		<td>103</td>	=3D09
		<td>76</td>
	</tr>
</table>


<table>
	<tr>	=3D09
		<td>49</td>
		<td>76</td>
		<td>103</td>
	</tr>
	<tr>
		<td>76</td>
		<td>49</td>
		<td>103</td>
	</tr>
</table>


/Robert


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