Solved

html table and moving cell sizes

Posted on 2010-11-26
8
169 Views
Last Modified: 2012-05-10
i am using ie and trying to make up a grid like excel but when you enter in the data if its longer than the cell then the cell will expand. what i want to do is to have the cell grow in height to make the adjustment instead of in width. the data is being returned via ajax and will have many
differing characer count as the data is returned

$ret.='<table>';
<td width="152" style="width:152">'.$nyz'</td>
<td width="152" style="width:152">'.$123.'</td>
<td width="152" style="width:152">'.$abv.'</td>
<td width="152" style="width:152">'.$xyz.'</td>';
            
$ret.='</table>'; data layup
0
Comment
Question by:sydneyguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 18

Accepted Solution

by:
Sudaraka Wijesinghe earned 167 total points
ID: 34220975
If you have continuous string in the TD, you won't be able stop it from expanding. You can add a DIV tag in the TD and set a fixed width to that and set overflow to hidden. (extra text will be cut off from the display)

Btw, Add TR tags around the TDs.

Found this here http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/HTML/Q_21605705.html
<td><div style="width:152px; overflow;hidden;">'.$nyz'</div></td>

Open in new window

0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 167 total points
ID: 34220987
If you're trying to get all the sections to line up together, you need to make it One table and not a bunch of little ones.  If it's One table, then all of the columns will have the same width from top to bottom.  Start the table at the top, loop thru your data, and end the table after the loop.  Like below:
echo '<table>';
///
while(...) {
$ret.='<tr>';
$ret.='<td width="152" style="width:152">'.$nyz'</td>
<td width="152" style="width:152">'.$123.'</td>
<td width="152" style="width:152">'.$abv.'</td>
<td width="152" style="width:152">'.$xyz.'</td>';            
$ret.='</tr>'; 
}
echo '</table>';

Open in new window

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 34220990
This would be better.
echo '<table>';
///
while(...) {
$ret = '<tr>';
$ret.='<td width="152" style="width:152">'.$nyz'</td>
<td width="152" style="width:152">'.$123.'</td>
<td width="152" style="width:152">'.$abv.'</td>
<td width="152" style="width:152">'.$xyz.'</td>';            
$ret.='</tr>'; 
echo $ret;
}
echo '</table>';

Open in new window

0
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 
LVL 13

Assisted Solution

by:gbanik
gbanik earned 166 total points
ID: 34222764
Just echo this before the body
echo '<STYLE>td {width:152px;vertical-align:top}</STYLE>';
and create your table and columns without any width.

If you are filling data by AJAX, it may be better to use DIVs rather than TABLEs and TDs.
0
 
LVL 13

Expert Comment

by:gbanik
ID: 34222772
and of course do what DaveBaldwin suggested... create ONE table rather than many small ones. Data within cells (cell widths) are restricted by column widths across all rows of the table.
0
 

Author Comment

by:sydneyguy
ID: 34223494
thanks for that am playing with a sample file now so will know by the end of the day. when we have it going.
welcome to a fantastic sunday every one,
0
 

Author Closing Comment

by:sydneyguy
ID: 34398829
thanks for the help rebuit the lay out and now works fine
have a good christmas and a good new year
0
 
LVL 18

Expert Comment

by:Sudaraka Wijesinghe
ID: 34399250
Glad to help. Thanks for the points.
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

734 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