Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use javascript to layer a div below a input box 1

Status
Not open for further replies.

xpblueScreenOfDeath

Programmer
Sep 1, 2004
87
How do I use javascript to layer a div right below a input box like in
I do not want to have to put the postion in the input box like so: <INPUT TYPE=TEXT STYLE="POSITION: absolute; LEFT: 40px; TOP: 30px; HEIGHT: 10px">

It would be nice if I can find the exact position and height of the input box on the browser with a input define like so: <INPUT TYPE=file ID=test>

Thanks in advance.
 

Here you go:

Code:
<html>
<body>
	<form>
		<div>
			<input type="text" />
			<div style="margin-left:auto; margin-right:auto;">Your content here</div>
		</div>
	</form>
</body>
</html>

Hope this helps,
Dan

 

In fact, you don't even need the margin style on the second DIV - it is lined up right below the input box anyway.

Dan

 
Thanks BillyRayPreachersSon

Now, how do I make it so the inner div is not part of the layout so that it doesn't take up any space when it is unhidden and overlaps the contents below the input box.


<html>
<HEAD>
<SCRIPT Language=javascript>
function display()
{
var a = document.getElementById("test");
a.style.visibility = "";
}
</SCRIPT>
</HEAD>
<body>
<form>
<div>
<input type="text" onclick="display();" />
<div id=test style="visibility: hidden; margin-left:auto; margin-right:auto;">Your content here</div>
</div>
This is a test
</form>
</body>
</html>
 

Change the outer div and its contents to be:

Code:
<div>
   <input type="text" onclick="display();" /><br />
   <div id=test style="position:absolute; visibility: hidden; margin-left:auto; margin-right:auto;">Your content here</div>
</div>

Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top