[Javascript] Inserting a spacer row
Steve Clason
stevec at topdogstrategy.com
Fri Apr 8 10:57:50 CDT 2005
Hello,
I have a script that works in Firefox but fails in Internet Explorer and
Safari and would appreciate some help.
As part of a CMS for fitness company, we've made weekly exercise
schedules that instructors without great html skills will be
maintaining. To make their lives easier, we wanted to insert a row with
a red line above any table row that contained a day of the week (except
Monday).
Here's the script:
function makeSpacer()
{
var schedule = document.getElementById("schedule");
var cell = schedule.getElementsByTagName("td");
for (var i=0; i<cell.length; i++)
{
if (cell[i].innerHTML == ("Tuesday") ||
cell[i].innerHTML == ("Wednesday") ||
cell[i].innerHTML == ("Thursday") ||
cell[i].innerHTML == ("Friday") ||
cell[i].innerHTML == ("Saturday") ||
cell[i].innerHTML == ("Sunday"))
{
row = cell[i].parentNode;
newRow =
row.parentNode.insertBefore(document.createElement('tr'), row);
newCell = newRow.insertCell(0);
newCell.setAttribute("colspan", 5);
newCell.setAttribute("class", "spacer");
newCell.innerHTML = " ";
i++;
}
}
}
And the relevant CSS:
.spacer{
height: 2px;
background-image: url("/images/red1x2.gif");
background-repeat: repeat-x;
background-position: bottom;
}
I've also tried the CSS with borders and background colors with the same
results.
In Firefox I get a new row above the rows containing the days of the
week. In Safari I get a red line only above the cell containing the day
of the week, in Internet Explorer I get just the new row, no red line.
Anyone have any suggestions? You can see a draft page at (watch the wrap):
http://dev1.arieldesign.com/index.cfm?objectid=52AE2B25-D612-00A6-AA2FD44A87E48724
Thanks for any help you can offer.
--
Steve Clason
Web Design and Development
Boulder, Colorado, USA
www.topdogstrategy.com
(303)818-8590
More information about the Javascript
mailing list