Resizing table height

J

JMT

Hello,

I get some dynamic controls (ASP .Net) inside a table, the height
property of the table is variable according the controls loaded, so I
need to know the final table height, this value must be an odd number
by graphic design. I put the next code at bottom of the page;


<script type="text/javascript" language="JavaScript1.2">


if (document.getElementById("TABLE1").clientHeight%2 == 0)
document.getElementById("TABLE1").height =
document.getElementById("TABLE1").clientHeight + 1;

</script>


Works fine in IE6 & IE7, in Firefox 2 and Opera 9 doesn't works, I've
checked with alert(document.getElementById("TABLE1").height)
and I can see the result desired, but the height of the table remains
and doesn't change in the page. ¿Is there any solution for it works
in Firefox and Opera?


Many thanks.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

JMT said:
Hello,

I get some dynamic controls (ASP .Net) inside a table, the height
property of the table is variable according the controls loaded, so I
need to know the final table height, this value must be an odd number
by graphic design. I put the next code at bottom of the page;


<script type="text/javascript" language="JavaScript1.2">


if (document.getElementById("TABLE1").clientHeight%2 == 0)
document.getElementById("TABLE1").height =
document.getElementById("TABLE1").clientHeight + 1;

</script>


Works fine in IE6 & IE7, in Firefox 2 and Opera 9 doesn't works, I've
checked with alert(document.getElementById("TABLE1").height)
and I can see the result desired, but the height of the table remains
and doesn't change in the page. ¿Is there any solution for it works
in Firefox and Opera?


Many thanks.

There is no height property for the table tag, that's why it doesn't
work in standards compliant browsers. When you set the height property,
a new member is created in the table object, but it's not used for anything.

Use the style.height property to set the height of the table. Don't
forget to append the 'px' unit when you set the value.
 
J

JMT

Thank you Göran, now it works!

if (document.getElementById("TABLE1").clientHeight%2 == 0)
document.getElementById("TABLE1").style.height =
parseInt(document.getElementById("TABLE1").clientHeight + 1) + 'px';

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top