• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to adjust the size of a table according to its outer cell size?  RSS feed

 
Adithya Rayaprolu
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have used tables for the layout of my form. The table width should be 100%, means it should occupy the whole browser window. In that table, I have a row with 2 columns. Each column again has tables. First column is fixed size, so I set its width as certain pixels. Second should occupy whatever width is left, even if its 0. So, I specified its width as *. I have to create a table of data dynamically in this cell. When the table is large, its occupying the size more than the browser window, I mean its stretching the entire document. but I want that table to be fixed in its cell. How can I do this?
Thanks for your time.
 
christoph weingarten
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let's say your code looks like this:
(table width=100%)
(tr)(td)
(table width=300)(tr)(td)data(/td)(/tr)(/table)
(/td)
(td)
(table width=*)(tr)(td)(img src='my.gif')(/td)(/tr)(/table)
(/td)(/tr)
(/table)
furthermore let's say you have a screen-width of 640 pixel. so the table in the second collum normally has a width of 340 pixels.
but if you insert a image with a width of 400 pixels here, there is not enough screen-width to display everything on your page without scrollbars.
for an image it's no real problem, because you can set it's width, too. but if you paste a word in there, you'll get in trouble.
 
Adithya Rayaprolu
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We got the solution for this problem. We used a function the code in which is
wid = document.body.clientWidth-400;
var ele = document.getElementById("tabeId");
ele.style.width = wid;
And calling this function in body onResize event. The 400 is fixed, we will not change it later, its the size of the other portion in the screen which is constant.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!