Solved

html table and moving cell sizes

Posted on 2010-11-26
8
166 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 82

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 82

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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now