I have two floated divs: a #center div and a #sidebar div. Center div has got updatable text in it and so its height is set to "auto". The sidebar div also has height auto but, right underneath a scrolling div with definite height, it continues till reaching the bottom of the first div. I want to fill this different space by loading a proper class (each with different backgrounds and different heights). So far I managed to create a js script that retrieves center div height and displays a msg according to its value.
<div id="center">
<p>Some long text</p>
</div>
<div id="sidebar">
<div class="scroller"></div>
<script type="text/javascript">
var gd;
function getDivHeight(divID){
gd = document.getElementById('center').offsetHeight;
if(gd <=400) alert("no space");
else if(gd >400 <=500) alert("short space");
else if(gd >500 <=600) alert("mid space");
else if(gd >600 <=700) alert("large space");
else if(gd >700) alert("too much space");
}
getDivHeight('center');
</script>
What I don't know is how can I use that gd value to load a certain class or div. Can it be done all in JS or do I need some php.... I'm a newbee in both of them and can't really find my way around without some help. Any suggestion or hint that could put me on the right track will be highly appreciated
thx
Alberto