Click to See Complete Forum and Search --> : DOM Level 1 and editing table values


wallabee
08-18-2003, 12:28 PM
I'm currently trying to write some JavaScript which will detect the resolution of the user's monitor, and then size the image within the table and the size of one of the column's width to a lower or higher value, accordingly. I have no problem editing the image's width value, and I have no problem editing the table's width value as well. However, I don't want to actually edit the TABLE's width, i want to edit the <TD> width, which I can't seem to do. Any advice? Code below.


<HTML>
<BODY>

<table ID="Table1" height="247" border="1">
<tr>
<td ID="column1" bgcolor=#CCCCC width="63%" height="241">&nbsp;</td>
<td ID="column2" bgcolor=#0b333 width="37%"><img id="Image1" src="porpoise.jpg" width="318" height="237"></td>
</tr>
</table>


<SCRIPT language="JavaScript">
if ((screen.width>=1024) && (screen.height>=768)){
document.getElementById("Image1").setAttribute("width",500);
document.getElementById("column1").setAttribute("width",200);
} else {
document.getElementById("Image1").setAttribute("width",300);
document.getElementById("column1").setAttribute("width",600);
}
</SCRIPT>
</BODY>
</HTML>


-wallabee

Khalid Ali
08-18-2003, 12:48 PM
instead of html width attribute use CSS width.