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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting height of Text element

Status
Not open for further replies.

culshaja

Programmer
Aug 10, 1999
705
GB
Hi,

I am wanting to get the height of a textbox in a form. I want to show a layer directly underneath it, and I can get the top position of the control but I can't add the height to it as they are no numbers they are straings as they contain non-numeric characters.

Could anyone shed some light on how I could do this?

Thanks,

James :) James Culshaw
james@miniaturereview.co.uk
 
I'm not quite clear on what you wanted, but the following code will resize the layer to be equal to the textbox and then place the layer directly underneath the text box. If you weren't looking for that, you can still take and use what you need from the code.
Code:
<script>
<!--
onload = placeObj;

function placeObj() {
	obj.style.width = box.offsetWidth;
	obj.style.height = box.offsetHeight;
	obj.style.left = box.offsetLeft;
	obj.style.top = box.offsetTop;
}
//-->
</script>

<div id=&quot;obj&quot; style=&quot;position:absolute;background-color:Black&quot;></div>
<input type=&quot;text&quot; name=&quot;box&quot; style=&quot;position:absolute&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top