Hey there! I'm facing an issue with a main div that contains 2 other divs. I need the height of the lower div to change dynamically based on the resize of the main div.
Here's the code I have so far:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<style type="text/css">
#upper{
background:#F00;
border: black solid 2px;
overflow-y:scroll;
height: 50px;
}
#lower{
background:#AAF;
border: red solid 2px;
overflow-y:scroll;
}
#maindiv{
height: 100%;
border: green solid 2px
}
html,body{margin: 0px;}
</style>
</head>
<body id="bodyId" >
<div id="maindiv">
<div id="upper">test<br/>
test<br/>
test<br/>
test<br/>
test<br/>
v
test<br/>
test<br/></div>
<div id="lower" onresize="resize('lower')">test2</div>
</div>
<script type="text/javascript">
function resize(arg)
{
var frame= document.getElementById(arg);
var heights= document.getElementById(arg).parentNode.offsetHeight ;
alert(frame);
frame.style.height = heights -50 + "px";
}
</script>
</body>
</html>
I'm having trouble getting it to work. My goal is to pass the id of the lower div (lower) to a function, retrieve the id and height of the parent div (maindiv), and set the height of the lower div accordingly.
Any insights or suggestions would be greatly appreciated!
Thanks in advance for your assistance.
Sincerely, TheVagabond