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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting a table

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
OK, hopefully last question while I am working on HTML side of this project...
I have a table with 2 nested tables such as:
<TABLE width=650 style=...> <--this is main table
<TD>
<TABLE>contents..</TABLE> <--first nested table
</TD>
<TD>
<TABLE>contents..</TABLE> <--second nested table
</TD>
</TABLE>
As you see, the nested table display one next to another
Question:
How do I make it so the first nested table is, say, 70% of the length of the main table (my problem is that the first table has many columns and the data varies in those columns(jenerated by java program), and when the data is long, the data looks wrong). So basically I want to set the constant length to the first nested table, I want it always to take up about 70 % of the main table length, no matter what data is populated in there

you guys been great, thanks for all your help
 
if by "length" you mean "width" then;

Code:
<TABLE width=650 style=...>  <--this is main table
<tr>
<TD width="70%">
<TABLE>contents..</TABLE>  <--first nested table
</TD>
<TD>
<TABLE>contents..</TABLE>  <--second nested table
</TD>
</tr>
</TABLE>

should do the trick...

NOTE: you forgot the "<tr></tr>" tags.
 
ok, this seems to work, but it looks liek the width is not set permanently, when the data is long, the first inner table becomes bigger. Does width tag overpowered by length of data?

thanks
 
Change the background colors of the table cells so you can see just how big they REALLY are. You might find that the cell that SHOULD be 30% IS 30%, but that the content doesn't fill it up.

If it doesn't appear to be working even then, you can change the size of the cell-in-question to 70% when the document loads.

Here is a small sample of code that does both these things:

Code:
<html>
<head>
<script>
function formatTable()
{
 seventy.style.width = "70%";
}
</script>
</head>
<body [b]onload="formatTable();"[/b]>
<table>
<tr>

<td id="seventy" [b]style="background-color:'blue'"[/b] width="70%">this is some really sizable content that ought to overpower the table and make this 70% column even LARGER than that!</td>

<td [b]style="background-color:'yellow'"[/b]>not much here</td>

</tr>
</table>
</body>
</html>

Something else you should do is set the width of the embedded tables to 100% (to fill their cells):

<td width="70%"><table width="100%"> ... </table></td>

'hope that helps.

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top