Table Wrapping

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
labert_the_old
Forum Newbie
Posts: 5
Joined: Fri Jun 13, 2003 7:22 pm

Table Wrapping

Post by labert_the_old »

Hi There,

Does any one know how to wrap tables? What I want this to do is basicly have a bunch of tables beside each other depending on the size of the browser window wrap them down to the next line.

Heres a simple example.

Code: Select all

<html>
<head>
</head>

<body>
<table width="50" border="1" cellspacing="1" cellpadding="1" align="right">
  <tr>
    <td> </td>
  </tr>
</table>
<table width="50" border="1" cellspacing="1" cellpadding="1" align="right">
  <tr>
    <td> </td>
  </tr>
</table>

</body>
</html>
For the above I just want it second table to drop down to the next line if shrink your browser window.

Heres the more complex example of my acutal code.

Sincerley,

Lambert the Old

Code: Select all

<?php

if ($_SESSION['view_cal'] == 0)
{
  
 $y2 = date("Y");
 
 echo "<h3>Unit: " . $_SESSION['editchoice_view_cal'] . "";
 echo "<h3>Calendar Year For: $y2</h3><br>\n";
 
 $counter = 0;
 echo "<table width="100%" border="0" cellspacing="0" cellpadding="1">";
 echo "<tr>\n";
 echo "<td>&nbsp;</td>"; 
 while($counter < 12)
 {
  
  if( !$y )
  {
   $y = date("Y");
  }
  if( !$m )
  {
   $m = date("m");
  }
   $_SESSION['view_cal'] = 0;
  $mymonth = new month($m,$y);  
  
  echo "<table width="15%" cellpadding="0" cellspacing="0" border="0" align ="right">\n";
  echo "<tr>\n";
  echo "  <td bgcolor="#00cc65">\n";
  echo "<h3>$mymonth->month_name</h3><br>\n";
  $mymonth->draw(array("cellspacing" => "1" , "cellpadding" => "1" ,
                      "top_row_align" => "center" , 
                      "top_row_cell_height" => 1 , "bgcolor" => "#cccccc" ,
                      "row_align" => "left" , "row_valign" => "top" ,
                      "font_size" => "-2") );

  echo "  </td>\n";
  echo "</tr>\n";
  
  
  
  $counter++;
  $m=$mymonth->nextmonth;
  $y=$mymonth->nextyear;
 
 }//while

  echo "</td>\n";
  echo "</tr>\n";
  echo "</table>\n";
  
//<a href="./cal.php?m=<?php echo $mymonth->prevmonth; &y=<?php echo $mymonth->prevyear; &y2=<? echo $y2 -1 ">Prev.</a>&nbsp; 
?>
<p><a href="./cal.php?m=<?php echo $mymonth->prevmonth; ?>&y=<?php echo $mymonth->prevyear; ?>">Prev.</a>&nbsp; 
  <a href="./cal.php?m=<?php echo $mymonth->nextmonth; ?>&y=<?php echo $mymonth->nextyear; ?>">Next.</a> 
</p> 

</body>
</html>
<?
 echo "<A HREF="../guest_view_unit.php"> BACK TO VIEW UNIT VIEW </A><br>";
}//if


?>
?>
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

You will need to use JavaScript if you want to check if the browser window has been changed.

Code: Select all

<script language="JavaScript">
window.onresize=function()&#123;
//function stuff
//
//you would need to reload the page so that the php
//code can run through again and draw your table
//
window.location.href="your_page.php";
&#125;
</script>
I think that works but I haven't tested it.


Hope that helps.
Post Reply