473,804 Members | 4,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7084
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 misunderstandin g. 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
3895
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 image. Here is the class method, it obviously doesn't work: /**
12
14519
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, that has limited width but multiple lines. Currently I am using the left$() function to trim the text to a standard number of characters. I want a function to return the number of characters that will fit in the width of the control. To keep the...
4
6377
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 (cost). Users can dynamically add rows to the table so I don't know how many rows might need to be calculated. I need to calculate the total (qty * cost) and put that number in a table cell (or read only input box). I also need to sum the...
2
1622
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 textarea should be made bigger while typing programatically. my only problem is to determine the size of the string in the textarea. i know the font family and font size.
7
43951
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 object. 4. If string size is less than the size of the rectangle, we are done.
5
2632
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
1518
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
6078
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 some .NET code on the server. Because the message information that is within this <div> is dynamic, it can be several lines long...also the message box <div> can be variable widths wide as well. Therefore, I need a Dependable way to dynamically...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.