Hello everyone, I have an issue, I am making a website at the moment using multiple divs as usual, but there is a probably with two of my divs. Events and News, event is supposed on the left side of the container on EVERY page of the website, which I accomplished , but whenever I set the height of the div to be 100%, it only extends down so far, it does not extend down the ENTIRE container. It only extends a little bit past the bottom of the last event I put on it, oh, and btw, news and events both read and list their sources from a database, so they could be virtually any height.

this is the index.php

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sachem East Deca</title>

<style type="text/css"> 
<!-- 
body  {
	font: 100% Verdana, Arial, Helvetica, sans-serif;
	height: 100%;
	background: #666666;
	background-color: #003;
	margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
	padding: 0;
	text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
	color: #000000;
}

.EastDecaMain #container { 
	width: 75.0%;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
	background: #FFFFFF;
	margin-top: 10;
	top: 10;
	margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
	border: 2px solid #FFF;
	text-align: left; /* this overrides the text-align: center on the body element. */
}

.EastDecaMain #mainContent { 
	margin: 0px 0px; /* the right and left margins on this div element creates the two outer columns on the sides of the page. No matter how much content the sidebar divs contain, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the sidebar spaces when the content in each sidebar ends. */
    padding: 0px 0px 0px 0px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}

.EastDecaMain #mainContent news{ 
	margin: 0px 0px;
	/*margin: 10px 10px; /* the right and left margins on this div element creates the two outer columns on the sides of the page. No matter how much content the sidebar divs contain, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the sidebar spaces when the content in each sidebar ends. */
	padding: 0px 0px 0px 0px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}

.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
	float: right;
	margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page */
	float: left;
	margin-right: 8px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
	clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}

--> 
</style><!--[if IE 5]>
<style type="text/css"> 
/* place css box model fixes for IE 5* in this conditional comment */
.EastDecaMain #sidebar1 { width: 180px; }
.EastDecaMain #sidebar2 { width: 190px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css"> 
/* place css fixes for all versions of IE in this conditional comment */
.EastDecaMain #sidebar2, .EastDecaMain #sidebar1 { padding-top: 30px; }
.EastDecaMain #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>

<?php include("includes/header.php") ?>
<?php include("includes/navmenu.php") ?>
<?php include("includes/events.php") ?>

<body class="EastDecaMain" onload="$("#events").height($("#mainContent").height())">
    <div id="container">
      <div id="mainContent">
          <div id="news">
          	<br /><br /><br />
                    <?php
                        $user="root";
                        $password="1003037";
                        $database="deca_web";
                        mysql_connect(localhost,$user,$password);
                        @mysql_select_db($database) or die( "Unable to select database");
                        
                        $query="SELECT * FROM deca_news";
                        $result=mysql_query($query);
                        
                        $num=mysql_numrows($result);
                        
                        mysql_close();
                        
                        $i=0;
                        while ($i < $num) {
                            $author=mysql_result($result,$i,"author");
                            $datecreated=mysql_result($result,$i,"datecreated");
                            $news=mysql_result($result,$i,"news");
                            
                            echo "<br>
                                  <font size = 3 color = #0066FF><b>By $author</b></font>
                                  <br><font color = #CC0066 size = 2>Date of Creation: $datecreated</font>
                                  <br><br>$news<br>
                                  <hr />";
                            
                            $i++;
                        }
                    
                    ?>
           </div>
       </div>
       <br class="clearfloat" />
    </div>
</body>
<?php include("includes/footer.php") ?>
</html>

and this is the events div include

<style>
.EastDecaMain #events {
	float: left; /* since this element is floated, a width must be given */
	width: 200px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
	height: 100%;
	margin-right: 60;
	background: #999; /* the background color will be displayed for the length of the content in the column, but no further */
	/*padding: 5px 10px 15px 20px;  padding keeps the content of the div away from the edges */
	padding: 5px 10px;
}
</style>

<body class="EastDecaMain">

    <div id="container">
              <div id="events">
                    <h3><font color = red>Upcoming Events</font></h3>
                        <?php
                            $user="root";
                            $password="1003037";
                            $database="deca_web";
                            mysql_connect(localhost,$user,$password);
                            @mysql_select_db($database) or die( "Unable to select database");
                            
                            $query="SELECT * FROM deca_events";
                            $result=mysql_query($query);
                            
                            $num=mysql_numrows($result);
                            
                            mysql_close();
                            
                            $i=0;
                            while ($i < $num) {
                                $date=mysql_result($result,$i,"date");
                                $eventname=mysql_result($result,$i,"eventname");
                                
                                echo "<br>
                                      <font size = 3 color = #0066FF><b>$eventname</b></font>
                                      <br><font color = #CC0066 size = 2>Event Date: $date</font><br>
                                      <hr />";
                                
                                $i++;
                            }
                        ?>
                </div>
    </div>

</body>

As you can see, the events div's parent is container, while the news is child of mainContent which is a child of container. How can I set the height of the events div to be the SAME height as the NEWS div?

SOLVED:

I just added a JavaScript function at the head for setting the events div equivalent to the news div's height, and then called that function through an echo after the while loop in the news div.

The function went like this:

<script text/javascript>
      function SetHeight() {
		 document.getElementById("events").style.height = document.getElementById("news").clientHeight + 'px';
      }
</script>

and the news div update went like this

echo "<script language = javascript>SetHeight();</script>";

Hope this helps someone :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.