Jump to content


Photo

Auto-resizing rowspan for table column


  • Please log in to reply
2 replies to this topic

#1 Picatta

Picatta
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 25 July 2006 - 07:00 AM

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.homei...diasearch.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?

#2 just-j

just-j
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts

Posted 26 July 2006 - 06:08 AM

i dont know if you can do it it javascript  but i did mine in php somthing like
$textlen = strlen($line);
$rowspan = (round($textlen / 80) + 1);
if ($colspan < 4) { $rowspan = 4; }

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.

#3 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 28 July 2006 - 01:41 PM

I use embeded tables for this situation. Or seprerate tables. EX:
<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>

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users