It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Getting 2 div's to match height.

Getting 2 div's to match height.

Postby jatrant on Wed Jun 25, 2008 9:25 pm

Ok so after a day of doing research I have found great resources for very similar scripts but not exactly what i need. I need a script that will grab height of one SPECIFIC div and then apply it to another SPECIFIC div. The resources I have found have been match height of maximum div height overall.
I have been trying to play with a script i grabbed online but what i dont know what to do is point to the Specific Div i need....

Code: Select all
<script language="javascript">

    dynheight=function(){

         var divs,contDivs,maxHeight,divHeight,d,div2;

   

         divs=document.getElementsByTagName('mycontent');

         contDivs=[];

         for(var i=0;i<divs.length;i++){

                 if(/\bcontainer\b/.test(divs[i].className)){

                    d=divs[i];

                    contDivs[contDivs.length]=d;

                    // determine height for <div> element

                    if(d.offsetHeight){

                         divHeight=d.offsetHeight;

                    }

                    else if(d.style.pixelHeight){

                         divHeight=d.style.pixelHeight;

                    }

               

              }

         

         div2=document.getElementsByTagName('layer2');
      div2.style.height=divHeight;
         


       

   



    window.onload=function(){

         if(document.getElementsByTagName){

              dynheight();

         }

    }

    </script>


What i ultimately need it to do is look for the height for <div id="mycontent"> and apply the same height to <div id="layer2">.

I'm afraid no other work around will work for what i need, so I'm wondering if someone can help to get this script working.

Thanx
jatrant
 
Posts: 0
Joined: Wed Jun 25, 2008 6:28 pm

Postby rangana on Thu Jun 26, 2008 12:30 am

First, language is a deprecated attribute. Use type instead.
Secondly, show us your markups. We can't figure what's wrong.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 7 guests