Jump to content

Archived

This topic is now archived and is closed to further replies.

Picatta

Auto-resizing rowspan for table column

Recommended Posts

I was re-doing my website, but ran into a problem.  The top and bottomof my pages are brought up in includes, so I can't change one script wthout the rest getting messed up.  The problem is that while rowspan=4 i fine on most of my pages, some have more than 4 rows, and so do not work properly.  An example is http://picatta.homeip.net/googlemediasearch.php.  On the menu to the right, it is too short.  Is there a way of having it automatically resize to the number of table rows?

NOTE: I set rowspan to a large number, and it seems to work.  However, is there a better way of doing it?

Share this post


Link to post
Share on other sites
i dont know if you can do it it javascript  but i did mine in php somthing like
[code]
$textlen = strlen($line);
$rowspan = (round($textlen / 80) + 1);
if ($colspan < 4) { $rowspan = 4; }
[/code]

where $line = what i want to say in that <td>
and 80 is where i want the text to wrap around and i used wordwrap() for that. i had to round the number so i didnt get a decimal place then i added 1 just in case it rounded down. 
the if (....) statement is used because i want the rowspan to be at least 4
and for it to work i use echo "<td rowspan='$rowspan'>";

if you dont know php and dont have it installed then you cant do it...
i dont know if rowspan="auto" will work. i dont think it does though.. 
so learn php unless someone else has a solution.. im sure someone can do a javascript version similar to what i did in PHP that you would be able to  use without having to install anything new on your server.

Share this post


Link to post
Share on other sites
I use embeded tables for this situation. Or seprerate tables. EX:
[code]
<table width="775"><!--This table controls the overall shape of the page -->
<tr><td>

<table>
<tr>
<td>The top/banner</td>
</tr>
</table>

<table>
<tr>
<td>Content</td>
</tr>
</table>

<table>
<tr>
<td>Footer/bottom</td>
</tr>
</table>

</td></tr>
</table>
[/code]

And you can add as many rows and cols as you want in each table with out them screwing up the over all layout. You can also put you php includes in repalce of the tables that way you can edit everything seperately. Hope that helps a little.[/code

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.