I'm trying to mess about with a table using javascript. I'm deleting the
current row then adding a new row and adding a couple of columns. I then
want to add either a style attribute and add a border to the bottom of one
of the cells or add a class attribute and set it up in the stylesheet.
Problem is, when I try to use the setAttribute it doesn't do anything. In
fact when I try and set any attribute of cellLeft or cellRight such as
bgcolor=red; it does nothing. It sets the width ok though!
Can anyone spot the problem?? Codes below..
Cheers,
Andy
<SCRIPT LANGUAGE='JavaS cript1.2'>
function setMenuComment( arg)
{
//remove row
var tbl = document.getEle mentById('menuC ommentTable');
var lastRow = tbl.rows.length ;
if (lastRow > 0) tbl.deleteRow(l astRow - 1);
//add row
var lastRow = tbl.rows.length ;
var iteration = lastRow + 1;
var row = tbl.insertRow(l astRow);
row.setAttribut e('align', 'left');
// left cell
var cellLeft = row.insertCell( 0);
blank = document.create TextNode('blank ');
cellLeft.append Child(blank);
// right cell
var cellRight = row.insertCell( 1);
var pEl = document.create Element('p');
if(arg=='main') { text = document.create TextNode('intro duction area');
cellRight.setAt tribute('width' ,'750');}
else if(arg=='cv'){ text = document.create TextNode('perso nal profile and
information'); cellRight.setAt tribute('width' ,'600');}
else if(arg=='downlo ads'){ text = document.create TextNode('softw are and
documents to download'); cellRight.setAt tribute('width' ,'450');}
else if(arg=='links' ){ text = document.create TextNode('links to other
sites of interest'); cellRight.setAt tribute('width' ,'300');}
pEl.appendChild (text);
cellRight.appen dChild(pEl);
cellRight.setAt tribute("class" , "menuInfo") ;
}
</SCRIPT>
//html
<!-- Menu Info Area -->
<tr><td border="0">
<table border="0" align="center" cellpadding="0"
cellspacing="0" vspace="0" id="menuComment Table">
<tr>
<td class="menuBar" width="100%"
style="border-bottom:1px solid #DCDCDC"><a>&nb sp;</a></td>
</tr>
</table>
</td></tr>
//stylesheet
td.menuInfo
{
border-left:1px solid #DCDCDC;
border-bottom:1px solid #EFEFEF;
height: 20;
text-align: left;
vertical-align: middle;
line-height: 1;
}
current row then adding a new row and adding a couple of columns. I then
want to add either a style attribute and add a border to the bottom of one
of the cells or add a class attribute and set it up in the stylesheet.
Problem is, when I try to use the setAttribute it doesn't do anything. In
fact when I try and set any attribute of cellLeft or cellRight such as
bgcolor=red; it does nothing. It sets the width ok though!
Can anyone spot the problem?? Codes below..
Cheers,
Andy
<SCRIPT LANGUAGE='JavaS cript1.2'>
function setMenuComment( arg)
{
//remove row
var tbl = document.getEle mentById('menuC ommentTable');
var lastRow = tbl.rows.length ;
if (lastRow > 0) tbl.deleteRow(l astRow - 1);
//add row
var lastRow = tbl.rows.length ;
var iteration = lastRow + 1;
var row = tbl.insertRow(l astRow);
row.setAttribut e('align', 'left');
// left cell
var cellLeft = row.insertCell( 0);
blank = document.create TextNode('blank ');
cellLeft.append Child(blank);
// right cell
var cellRight = row.insertCell( 1);
var pEl = document.create Element('p');
if(arg=='main') { text = document.create TextNode('intro duction area');
cellRight.setAt tribute('width' ,'750');}
else if(arg=='cv'){ text = document.create TextNode('perso nal profile and
information'); cellRight.setAt tribute('width' ,'600');}
else if(arg=='downlo ads'){ text = document.create TextNode('softw are and
documents to download'); cellRight.setAt tribute('width' ,'450');}
else if(arg=='links' ){ text = document.create TextNode('links to other
sites of interest'); cellRight.setAt tribute('width' ,'300');}
pEl.appendChild (text);
cellRight.appen dChild(pEl);
cellRight.setAt tribute("class" , "menuInfo") ;
}
</SCRIPT>
//html
<!-- Menu Info Area -->
<tr><td border="0">
<table border="0" align="center" cellpadding="0"
cellspacing="0" vspace="0" id="menuComment Table">
<tr>
<td class="menuBar" width="100%"
style="border-bottom:1px solid #DCDCDC"><a>&nb sp;</a></td>
</tr>
</table>
</td></tr>
//stylesheet
td.menuInfo
{
border-left:1px solid #DCDCDC;
border-bottom:1px solid #EFEFEF;
height: 20;
text-align: left;
vertical-align: middle;
line-height: 1;
}
Comment