By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

calculate string width dynamically

P: n/a
hey everyone

i try to figure out how to calculate string width in a textarea while
typing in it.
the textarea has a fixed start width. when the string gets longer as
the textarea width, the textarea should be made bigger programatically
while typing.

my only problem is to determine the size of the string in the textarea.
i know the font family and font size.

who can help me?

thanks for your help

Oct 5 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
strauchdieb <pa***********@gmail.comwrote:
i try to figure out how to calculate string width in a textarea while
typing in it.
the textarea has a fixed start width. when the string gets longer as
the textarea width, the textarea should be made bigger programatically
while typing.

my only problem is to determine the size of the string in the
textarea. i know the font family and font size.
You could use ``onkeyup''-events. On every key-up read the size of the
string and then try to set cols/rows according to this value.
who can help me?

thanks for your help
HTH
../otto
Oct 5 '06 #2

P: n/a
thanks for your reply.
but i meant not the size/length of the string. i meant the WIDTH in
pixels of that whole string.

Otto Lang wrote:
strauchdieb <pa***********@gmail.comwrote:
i try to figure out how to calculate string width in a textarea while
typing in it.
the textarea has a fixed start width. when the string gets longer as
the textarea width, the textarea should be made bigger programatically
while typing.

my only problem is to determine the size of the string in the
textarea. i know the font family and font size.

You could use ``onkeyup''-events. On every key-up read the size of the
string and then try to set cols/rows according to this value.
who can help me?

thanks for your help

HTH
./otto
Oct 5 '06 #3

P: n/a
strauchdieb <pa***********@gmail.comwrote:
thanks for your reply.
but i meant not the size/length of the string. i meant the WIDTH in
pixels of that whole string.
Sorry for my misunderstanding. I think that you can't change the
pixelwidth of a string via JavaScript.

../otto
Oct 5 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.