Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > display number of characters in textarea box

Reply
Thread Tools

display number of characters in textarea box

 
 
tony wong
Guest
Posts: n/a
 
      09-11-2005
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


 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      09-11-2005
Zoe Brown said the following on 9/11/2005 2:31 PM:
> "tony wong" <(E-Mail Removed)> wrote in message
> news:43244931$1@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.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
 
Reply With Quote
 
 
 
 
mscir
Guest
Posts: n/a
 
      09-11-2005
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
 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      09-12-2005
"Randy Webb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Zoe Brown said the following on 9/11/2005 2:31 PM:
> > "tony wong" <(E-Mail Removed)> wrote in message
> > news:43244931$1@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.javascript FAQ - http://jibbering.com/faq & newsgroup weekly


<html>
<head>
<title>count.htm</title>
<script type="text/javascript">
function count(that) {
window.status = that.value.length;
}
</script>
</head>
<body>
<form>
<textarea name="text" cols="50" rows="10" onkeyup="count(this)"></textarea>
</form>
</body>
</html>


 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      09-12-2005
McKirahan said the following on 9/11/2005 8:21 PM:
> "Randy Webb" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>Zoe Brown said the following on 9/11/2005 2:31 PM:
>>
>>>"tony wong" <(E-Mail Removed)> wrote in message
>>>news:43244931$1@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.javascript FAQ - http://jibbering.com/faq & newsgroup weekly

>
>
> <html>
> <head>
> <title>count.htm</title>
> <script type="text/javascript">
> function count(that) {
> window.status = that.value.length;


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.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      09-12-2005
Zoe Brown wrote:
> "tony wong" <(E-Mail Removed)> wrote in message
> news:43244931$1@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="document.getElementById('count').innerHTM L=this.value.length;">
</textarea>
<p id="count">


--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add </textarea> within <textarea> tags? frank.moens@gmail.com Javascript 1 07-04-2007 04:00 PM
Textarea Inside of a textarea wperry1@gmail.com ASP General 6 02-05-2006 08:00 AM
Feedback The Number of Characters Entered Into Textarea? clintonG ASP .Net 4 10-17-2005 02:47 PM
Interrogating string for number of characters, response.writing identical number of characters on new line Ken Fine ASP General 2 02-05-2004 03:40 AM
Removing carriage returns from <textarea></textarea> input Augustus ASP General 1 09-10-2003 04:55 AM



Advertisments