Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get the actual table width in pixel

Status
Not open for further replies.

khennes02

Programmer
Joined
Jun 22, 2004
Messages
6
Location
DE
Hi everyone.

I built a Page that with a Table in it.
The table is filled with information from a Database.
How can I get the actual width of the Table?
I need this information to be able to set the Printer settings.
Thanks Kai
 
why not set a standard with to the table???

Known is handfull, Unknown is worldfull
 
I cant set the width, because when I start the table I do not know how many columns will be added, and the information are VDA Standards, and the must be shown without a line break.

Here is what I tried that acutely returned something.
script type="text/javascript">
<!--

var w = window.innerWidth;
//returns window size
var w = document.body.scrollWidth;
//also returns window size

alert(w);
-->
</script>
 
You need to give the table an id, then use this id to get the table width.

eg id="table1"

Then use this code in you script

Code:
tableWidth = document.getElementById("table1")[COLOR=red].width[/color];

I think this should work, but i'm not sure of the exact syntax for the bit in red.

Hope this is of help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top