It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

change width table TD cell

change width table TD cell

Postby lvermeersch on Sun Sep 18, 2005 4:46 pm

I want to change change the table TD cell.
I know how to do this with a jscript and this works
in IE en FireFox but not in opera. The column Links i want to change to 50 px is not set to its correct width (seems mutch to large)!

The code, a two column one row table

<table border="1" width="800px">
<tr>
<td id="Links" width="200px">oke1
</td>
<td id="Rechts" width="600px">oke2
</td>
</tr>
</table>

<script language="javascript">
Links.width="50px";
</script>


I can give cell Rechts a width of 600px or zet it to * value that doesnt help.I set
I do set the column Links first to a value and later to a smaller value with a script.
I do want to use it in a script, because i need it for other code as well.

What am i doing wrong? It looks simple streightforward code to me.
lvermeersch
 
Posts: 13
Joined: Thu Aug 25, 2005 9:30 am

Postby lvermeersch on Mon Sep 19, 2005 9:44 am

I got allso a solution from an other forum, see code at bottom.
I used this example exactly and tested it.
And still the same result i'm afraid.
I tested in IE 6.0 and FireFox 1.0.6 and this works i see the column change to 50px.
Now with opera 8.01 i see allso the column getting smaller but only slightly
it stays at +- 175px width and not 50px !
I have tested on several PC's with Winxp and opera 8.01 same result.
Very strange, what's going wrong here?


<table border="1" width="800px">
<tr><td id="Links" width="200px">oke1</td><td id="Rechts" width="*">oke2</td></tr>
</table>

<script language="Javascript">

function setTdWidth()
{
alert('pause');

document.getElementById('Rechts').style.width = "750px";
alert(document.getElementById('Rechts').style.width);
var settd = document.getElementsByTagName('td');
for (x = 0; x < settd.length; x++) if (settd[x].getAttribute('id') == 'Links') settd[x].style.width = "50px";
}

setTdWidth();

</script>
lvermeersch
 
Posts: 13
Joined: Thu Aug 25, 2005 9:30 am


Who is online

Users browsing this forum: No registered users and 4 guests