473,803 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

display number of characters in textarea box

i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

Thanks a lot.

Tony
Sep 11 '05 #1
6 11641

"tony wong" <x3*@netvigator .com> wrote in message
news:43******** @127.0.0.1...
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?


create an event for the onchange value of the textarea, get the value of the
textarea and then count the chars.

HTH
Sep 11 '05 #2
Zoe Brown said the following on 9/11/2005 2:31 PM:
"tony wong" <x3*@netvigator .com> wrote in message
news:43******** @127.0.0.1...
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

create an event for the onchange value of the textarea, get the value of the
textarea and then count the chars.


Use the onkeyup instead, and after onkeyup you check the character
count. onchange will only fire *after* the textarea has lost focus.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 11 '05 #3
tony wong wrote:
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.
is it possible to do it by javascript?
Thanks a lot.
Tony


http://www.google.com/search?hl=en&l...ox&btnG=Search
2nd hit (google is your friend)

http://www.cs.tut.fi/~jkorpela/forms/textarea.html

Mike
Sep 11 '05 #4
"Randy Webb" <Hi************ @aol.com> wrote in message
news:T_******** ************@co mcast.com...
Zoe Brown said the following on 9/11/2005 2:31 PM:
"tony wong" <x3*@netvigator .com> wrote in message
news:43******** @127.0.0.1...
i wish to count number of characters in textarea box during typing in anddisplay it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

create an event for the onchange value of the textarea, get the value of the textarea and then count the chars.


Use the onkeyup instead, and after onkeyup you check the character
count. onchange will only fire *after* the textarea has lost focus.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly


<html>
<head>
<title>count.ht m</title>
<script type="text/javascript">
function count(that) {
window.status = that.value.leng th;
}
</script>
</head>
<body>
<form>
<textarea name="text" cols="50" rows="10" onkeyup="count( this)"></textarea>
</form>
</body>
</html>
Sep 12 '05 #5
McKirahan said the following on 9/11/2005 8:21 PM:
"Randy Webb" <Hi************ @aol.com> wrote in message
news:T_******** ************@co mcast.com...
Zoe Brown said the following on 9/11/2005 2:31 PM:
"tony wong" <x3*@netvigator .com> wrote in message
news:43***** ***@127.0.0.1.. .
i wish to count number of characters in textarea box during typing in
and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?
create an event for the onchange value of the textarea, get the value of
the
textarea and then count the chars.


Use the onkeyup instead, and after onkeyup you check the character
count. onchange will only fire *after* the textarea has lost focus.

--
Randy
comp.lang.jav ascript FAQ - http://jibbering.com/faq & newsgroup weekly

<html>
<head>
<title>count.ht m</title>
<script type="text/javascript">
function count(that) {
window.status = that.value.leng th;


Why the status bar? That will utltimately fail in Mozilla based browsers
that have the ability to script the status bar disabled.
And please fix your OE so that it does not quote signatures.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 12 '05 #6
ASM
Zoe Brown wrote:
"tony wong" <x3*@netvigator .com> wrote in message
news:43******** @127.0.0.1...
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

create an event for the onchange value


Not at all !
use : onkeyup
of the textarea, get the value of the
textarea and then count the chars.


<textarea
onkeyup="docume nt.getElementBy Id('count').inn erHTML=this.val ue.length;">
</textarea>
<p id="count">
--
Stephane Moriaux et son [moins] vieux Mac
Sep 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2499
by: JStrauss | last post by:
Hello, Can anybody give me some tips on the best and/or easiest way to display multiple lines in a field. The data is collected from a "textarea" field when the form is submitted, and I want to display all of the data (multiple lines) in a resulting HTML page. The data displays on a single line (obviously) and does not wrap without manipulation of the string variable. Is there an easier way to display the data? Thanks, Joe
2
22960
by: Francesco Moi | last post by:
Hello. I designed a form to edit some DataBase's fields. But some of these fields contain '&lt;' and '&gt;' characters. And these characters are '<' and '>' in HTML. So if want to edit these fields, the form converts them into '<' and '>'. And I want to mantain '&lt;' and '&gt;' Mi piece of code:
19
6936
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
2
1990
by: s.chelliah | last post by:
We have an input field which allows the user to enter a string of (up to 62) ASCII printable characters. We have a need to allow the user to be able to specify any sequence of characters he/she desires. However, we have a problem when we attempt to display this same string of characters. If the input sequence of characters contains HTML interpretable strings of characters, the user's sequence of characters is not properly displayed. (We...
8
3715
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special character you can imagine. My question is this, how do I save an exact copy of the textarea...
12
3863
by: comp.lang.php | last post by:
I have a textarea where people can cut & paste their resume. Unfortunately they often cut & paste their Word resume into the textarea, funky characters and all. This causes the display to be mangled from the HTML end when people view pages with these resumes stored as a MySQL text field entry. How do I fix this, also, how do I fix the displays of those already entered this way?
2
19590
by: xhe | last post by:
I met a very headache problem in javascript, I think this might be difference between IE and NS / Safari. I have a text area <form> <textarea name='tex1' onkeyup='displayit();'></textarea> </form> <span id="txtValue"></span> <script language='javascript'>
7
2156
Haitashi
by: Haitashi | last post by:
This is in the head: <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script>
7
17635
by: Anz | last post by:
Is there any javascript function for counting the number of lines inside a text area ?
0
9699
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
10309
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...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
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
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.