Wrox Home  
Search P2P Archive for: Go

  Return to Index  

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


Message #1 by "Robert Nyman" <robert.nyman@c...> on Thu, 3 Oct 2002 13:40:02 +0200
Hi Claudio,

good thing you liked the code!
I hope these answers will help you:

>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> ?
Yeah, sure, that sounds ok. But make sure you reference the frame
correctly, as in:
parent.mainFrame.getElementsByTagName("table") etc

>2- You said: "If you're only targetting IE, then exhange innerHTML to
innerText"
Well, it's a way of doing it more efficient in IE. But for both
browsers, innerHTML will be fine.
BTW, the code I sent will NOT work in Netscape 4, only Netscape 6 and
up.

>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??
No, it will function correctly no matter the attributes.


/Robert


-----Ursprungligt meddelande-----
Fr=E5n: Pallone, Claudio [KMR-SPC] [mailto:Claudio.Pallone@k...]
Skickat: den 3 oktober 2002 11:31
Till: JavaScript HowTo
=C4mne: [javascript_howto] RE: javascript_howto digest: October 02, 2002


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.


---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20


  Return to Index