Skip to main content
Inspiring
May 3, 2007
Answered

Height of input text box...

  • May 3, 2007
  • 2 replies
  • 813 views
Hi All,

Is there a way to dynamically get the height of a text input box throught javascript? For example, i have a <input type="text" id="myBox" size="50">, and I'd like to dynamically get the height of this text box with id "myBox" thru javascript.

Thanks in advance!
This topic has been closed for replies.
Correct answer Newsgroup_User
Daverms wrote:
> Hi,
>
> You can't retrive the height of the textbox since there is actually no "height" attribute is available for the <input type="textbox"> and also the width is represented as "size" attribute

a textbox CAN have HEIGHT and WIDTH defined in style= attribute.
if it does, you can get those values with
document.getElementById("yourid").style.height and
document.getElementById("yourid").style.width

however, WITHOUT setting height/width in the style= attribute you can't
get the default height/width of a textbox
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

2 replies

Newsgroup_UserCorrect answer
Inspiring
May 3, 2007
Daverms wrote:
> Hi,
>
> You can't retrive the height of the textbox since there is actually no "height" attribute is available for the <input type="textbox"> and also the width is represented as "size" attribute

a textbox CAN have HEIGHT and WIDTH defined in style= attribute.
if it does, you can get those values with
document.getElementById("yourid").style.height and
document.getElementById("yourid").style.width

however, WITHOUT setting height/width in the style= attribute you can't
get the default height/width of a textbox
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Inspiring
May 3, 2007
quote:

a textbox CAN have HEIGHT and WIDTH defined in style= attribute. if it does, you can get those values with
document.getElementById("yourid").style.height and
document.getElementById("yourid").style.width


I believe you can't do this Mr.Azadi.. Can you provide a piece of code for this?
Inspiring
May 3, 2007
Hi,

You can't retrive the height of the textbox since there is actually no "height" attribute is available for the <input type="textbox"> and also the width is represented as "size" attribute