views:

208

answers:

2

Hi again... I have tried different solutions but none of them work... So here is my last shot, if there is anybody out there who have done this or knows a way to do it please help me out...

I have two divs, one on the left, and one on the right side of my page. I have an iframe in the middle of my site, which content is loaded from a php file with mysql results in it. I want the two divs on my page to get the TOTAL height of my page and set it as its own height so the borders continue all the way down. I also would like the iframe to adjust its height depending on the "results_table" which "myPhpFile" echoes out.

Here is my two divs code:

   <div class="bgr_left">
   <div class="bgr_right">

Here is the css:

  .bgr_right {
background-image: url(../Graphics/bgr_right.jpg);
background-repeat: repeat-y;
background-position: right;
position: absolute;
top: 0px;
width: 30px;
right: 0px;
background-color: #E7F5F0;
    }

AND

   .bgr_left {
background-image: url(../Graphics/bgr_left.jpg);
background-repeat: repeat-y;
background-position: left;
position: absolute;
left: 0px;
top: 0px;
width: 30px;
background-color: #E7F5F0;
    }

And here is the iframe inside a table:

    <table width="850px" height="1000px" border="0" align="center">
    <tr>
    <td width="845px" height="998px">
      <iframe style="border:none; width:100%; height:100%;" name="iframe001"  src="frame.html" id="iframe001"></iframe>
    </td>
    </tr>
    </table>

And here is the form:

     <form id="nav_form_main" name="nav_form_main" action="bincgi/myPhp.php" target="iframe001" method="get">

And here is the part in the php file which creates a table from the mysql query:

      while($row = mysql_fetch_array($qry_result)){

My question: Is this way the best way to get two side borders on my page? AND, is there a way to set the iframe height to the content which is about to be loaded inside it from my "FORM"...

BACKGROUND HISTORY: I have a form on my site, which targets the iframe, and the action on the form is a php file which returns a mysql query result inside a table. So this table is what ends up inside the iframe!

+3  A: 

Trying to resize an IFrame onload using Javascript can be done but is very cumbersome in my experience. Using Ajax to dynamically load the PHP results into your HTML structure would be easier and more reliable. If you load the PHP output into a DIV, that DIV's height can increase the page's height, thus increasing the other DIVs' height.

Pekka
actually in my case ajax is far worse... but thanks anyways...
Camran
A: 

You can access an iframe content height with JavaScript only if both the iframe and the JavaScript are on the same domain.

You can try inserting content with PHP like:

$content = file_get_contents('http://domain.net/iframe.php');

//
//Do something with the content here
//

echo($content);

But it's not clear solution if you can't modify the iframe.php to get only content you need. I think you'll end up with static iframe height.

Petr Peller