Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

dynamic table width

Posted on 2008-06-24
6
Medium Priority
?
1,541 Views
Last Modified: 2008-06-30
hi there; i have a 700px table with 2 columns and many rows.

the first column has to be a dynamic width (i.e. as long as the longest content ... so if row 1 is 200px and row 2 is 240px and row 3 is 140px then the entire column will be 240px)

the second column has to be the remaining width (i.e.  if column 1 is 240px then column 2 is 460px ... if column 1 is 200px then column 2 is 500px etc ...)

can someone explain how i would accomplish this.

thanks.
0
Comment
Question by:vbnewbie01
6 Comments
 
LVL 2

Accepted Solution

by:
mriz81 earned 400 total points
ID: 21859086
You can achieve this by setting with of your second column to 700 and leave width attribute for first column. So a code like below can work for you
<table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>TestString</td>
    <td width="700">&nbsp;</td>
  </tr>
  <tr>
    <td>TestString_TestString</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>TestString_TestString_TestString</td>
    <td>&nbsp;</td>
  </tr>
</table>

Open in new window

0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 21859126
why don;y you use % FOR THE WIDTH
0
 
LVL 1

Author Comment

by:vbnewbie01
ID: 21860390
hi, erikTsomik; how would using percentage retain the exact width of the longest text in the first column?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Expert Comment

by:msfletch
ID: 21860518
You can try this:

<table width=700>
<tr>
    <td width=10 nowrap>Width 10 means at least ten, with no wrap it will stretch to fit content.</td>
    <td width="*">Star means everything left over to the width of the table</td>
</tr>
</table>
0
 
LVL 1

Author Comment

by:vbnewbie01
ID: 21861487
hi, msfletch; thanks for your suggestion.  i think i will go with mriz81's suggestion as i prefer not to have any minimum widths.  still waiting for erikTsomik's response before i ultimately decide though.  thanks again.
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21861516
At least you have something that works! =) The answer to erikTsomik's question is that it wouldn't retain the exact width.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question