473,382 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

calculate string width dynamically

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
3 7047
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: comp.lang.php | last post by:
Sorry folks, I'm on a roll!!! I need to calculate the height or width of an image if you change either the width or height and don't change BOTH of them at the same time, this is to "vector" the...
12
by: paii, Ron | last post by:
Sorry about that last one. Does anyone know how to calculate the width a string of text for given Font name and size? I want to buildup a block of text strings to display in a unbound control,...
4
by: Rich_C | last post by:
I'm sure this is very simple, but I have very little experience with javascript -- and what I do know isn't helping me here. I have a simple form where users can enter a quantity (qty) and cost...
2
by: strauchdieb | last post by:
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...
7
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics...
5
by: Michael | last post by:
Hi. I need dinamically calculate input text field based on parent static TD before showing content of input. Please, advice. Michael
3
by: bottomupthinker | last post by:
Hi all i have a string cotaining numeric values also. the font is courier New now i want to calculate its width please send the code
13
Frinavale
by: Frinavale | last post by:
Hi there! I've created a "message" box that consists of a <div> with a bunch of information in it and some buttons (which could be "ok", "yes", "no", "cancel"...). It's dynamically created with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.