HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 28th, 2003, 01:35 PM
cece cece is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 16 cece User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Word Count

Anyone have sample on Word Count.

There is a context box. And while the user typing into the box, the other box count and minus the character.

The count box may have a initial value of 200, and it getting less while the user typing.

Reply With Quote
  #2  
Old December 28th, 2003, 10:20 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
You can use the textbox or textarea's events, such as onChange. When the user types in a letter, a javascript function is called and it re-calculates the word count and updates the count box.

<textarea name="adtext" rows="8" cols="62" onChange="javascript:setTextCount();"></textarea>

The setTextCount function would get called each time the user enters a character. It would count of the text, peform the calculation, then update the count textbox.

Reply With Quote
  #3  
Old December 29th, 2003, 02:03 PM
cece cece is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 16 cece User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
but I need the script of javascript:setTextCount() in order to call it.

I do not know how to write the script to make it count n minus.

Reply With Quote
  #4  
Old December 29th, 2003, 08:45 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
The most reliable way to do this is to count how many characters the user has typed in, each time something in the textbox changes. Assuming your textboxes are called txtType and txtCount and your form is called form1, your function would look something like this below:

function setTextCount()
{
var nCurCount = document.form1.txtCount.value;
var nCnt = document.form1.txtType.value.length;
document.form1.txtCount.value = ( nCurCount - nCnt );
}

Your textbox would look like this:

<form name="form1">
<input type="text" name="txtType" onChange="setCount()">
</form>

Reply With Quote
  #5  
Old December 30th, 2003, 04:52 AM
cece cece is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 16 cece User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It works, Tq very much

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Word Count


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway