calculate string width dynamically

S

strauchdieb

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
 
O

Otto Lang

strauchdieb said:
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
 
S

strauchdieb

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

Otto Lang

strauchdieb said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top