Dynamische Zebrastreifentabelle in IE gehts, wie in NN4?
Stefan
- javascript
How can this script be functional with layers in NN4?
This script automatically alternates colors of table rows (one color for evens, one for odds) dynamically, meaning that no statically numbered names oder IDs have to be given to the rows. So rows can be deleted and inserted and the color stripes stay organized. There is no document.write command used, so the table can be edited WYSIWYGly in HTML-Editors as Dreamweaver.
Yours, Stefan Minder, University of Bern http://studmed.unibe.ch
<HTML>
<HEAD>
</HEAD>
<BODY>
<TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR NAME="construction_fields" ID="construction_fields">
<TD>Row 1</TD><TD>Row 1</TD><TD>Row 1</TD>
</TR>
<TR NAME="construction_fields" ID="construction_fields">
<TD>Row 2</TD><TD>Row 2</TD><TD>Row 2</TD>
</TR>
<TR NAME="construction_fields" ID="construction_fields">
<TD>Row 3</TD><TD>Row 3</TD><TD>Row 3</TD>
</TR>
<TR NAME="construction_fields" ID="construction_fields">
<TD>next Row</TD><TD>next Row</TD><TD>next Row</TD>
</TR>
<TR NAME="construction_fields" ID="construction_fields">
<TD>next Row</TD><TD>next Row</TD><TD>next Row</TD>
</TR>
<TR NAME="construction_fields" ID="construction_fields">
<TD>next Row</TD><TD>next Row</TD><TD>next Row</TD>
</TR>
<TR NAME="construction_fields" ID="construction_fields">
<TD>next Row</TD><TD>next Row</TD><TD>next Row</TD>
</TR>
</TABLE>
<SCRIPT>
var z=1;
function zebra(){
var objConstrFields = document.getElementsByName("construction_fields");
for(i=0;i<objConstrFields.length;i++){
z=z*-1;
if (z==1) objConstrFields[i].style.background='blue';
else objConstrFields[i].style.background='red';
}
}
function layzebra(){
// How would be the Zebrafunction for NN4 (with layers)
}
if (document.layers) layzebra();
else zebra();
</SCRIPT>
</BODY>
</HTML>
---
INFORMATION FÜR DOZIERENDE: Grosse Dateien können Sie uns auf http://studmed.unibe.ch/upload zustellen, da die Dateigrössen im E-Mailverkehr limitiert sind. Mehr Infos auf http://studmed.unibe.ch/tipps/tipps.htm
---
Stefan Minder
Web-Publisher
Inselspital 38
3010 Bern
Tel. 031 632 49 62
studmed@aum.unibe.ch
Kurs «Internetseiten herstellen»:
http://www.esdi.unibe.ch
Anwesenheitsplan AUM
http://studmed.unibe.ch/sm
Hello, Stefan ,
How can this script be functional with layers in NN4?
This script automatically alternates colors of table rows (one color for evens, one for odds) dynamically, meaning that no statically numbered names oder IDs have to be given to the rows. So rows can be deleted and inserted and the color stripes stay organized. There is no document.write command used, so the table can be edited WYSIWYGly in HTML-Editors as Dreamweaver.
Your code seems to work (tested with IE 5.5) - but actually it's not correct as you are using the same name and ID for different elements. This might cause problems in some browsers.
As the perentage of NS4 users is rapidly decreasing (presently about 10%) I wouldn't bother to offer them a "luxury feature" anyway ...
Regards,
Sebastian Becker
hi,
How can this script be functional with layers in NN4?
This script automatically alternates colors of table rows
to work with NC4x you have to use div-layers, which means _positioned_ divs (I would not use the old-fashioned layer-tag). Nc4x is _not_ able to change the color of tablecells after the document-rendering is done.
If there are _no_ other div-layers it is simple, because document.layers is an array of all layer-objects. So You are able to loop through all available layer-objects and change the css properties like color, position etc. Using "%" (modulo) You can set the color depending of the array key.
If there are other layers You have to find a way to exclude them, depending on Your source-code.
hth + regards Joachim