4 replies [Last post]
thepineapplehead
thepineapplehead's picture
Offline
Moderator
Last seen: 1 year 5 weeks ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819

Just a quickie. Got it working fine with one table using an ID. But how do I affect different tables with class="striped"?

Example here:

http://www.alistapart.com/d/stripedtables/example.html

Verschwindende wrote:
  • CSS doesn't make pies

DCElliott
DCElliott's picture
Offline
Leader
Halifax, Canada
Last seen: 6 years 4 weeks ago
Halifax, Canada
Timezone: GMT-3
Joined: 2004-03-22
Posts: 828
Points: 0

Zebra Stripes on ALA - classes?

First, let me state I don't know javascript worth a darn.

The method they have presented will stripe a single table. To do multiple tables you would have to expand the function to include the ability to iterate through multiple ids specified in the onload= event. One of the frustrations of working with javascript and CSS is that although there is a document.getElementById(id) function there is no comparable document.getElementByClass(class).

DE

David Elliott

Before you ask
LearnXHTML|CSS
ValidateHTML|CSS

thepineapplehead
thepineapplehead's picture
Offline
Moderator
Last seen: 1 year 5 weeks ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819

Zebra Stripes on ALA - classes?

Damn it, I was afraid of that.

Ah well, I guess I'll figure it out with many IDs.

Just one thing though - in the JS the two colors are specified; yet in the body tag, two different colors are specified. What is the reasoning? And which one affects the trs?

Verschwindende wrote:
  • CSS doesn't make pies

DCElliott
DCElliott's picture
Offline
Leader
Halifax, Canada
Last seen: 6 years 4 weeks ago
Halifax, Canada
Timezone: GMT-3
Joined: 2004-03-22
Posts: 828
Points: 0

Zebra Stripes on ALA - classes?

Well, your last question is easy - the colors in the JS are defaults in case the striping function was called with only the id name and neither of the color parameters - the color parameters are passed to variables with the two statments:
var evenColor = arguments[1] ? arguments[1] : "#fff";
var oddColor = arguments[2] ? arguments[2] : "#eee";
if the argument[1] exists - it becomes the evenColor and so on. Without the parameters the colors would be defaulted to that in the JS. (at least I know THAT much - LOL)

I'm wondering if it is possible to make two or more calls to the function with:
<body onload="stripe('id1', '#fff', '#edf3fe');stripe('id2', '#fff', '#edf3fe');stripe('id3', '#fff', '#edf3fe');">

DE

David Elliott

Before you ask
LearnXHTML|CSS
ValidateHTML|CSS

thepineapplehead
thepineapplehead's picture
Offline
Moderator
Last seen: 1 year 5 weeks ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819

Zebra Stripes on ALA - classes?

I'll have a look - cheers mate.

Verschwindende wrote:
  • CSS doesn't make pies