Solved

html table and moving cell sizes

Posted on 2010-11-26
8
168 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

680 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