TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

Javascript guru needed!

Page: 1 Reply
Dec 13th 2002#82162 Report
Member since: Mar 24th 2001
Posts: 3734
I'm looking for a javascript guru to help me change this script, since I'm javascript-stupid:

What this script does is count the number of characters in the texg box, but what I need it to do is to count the number of words.

If you can help me, I'll give you a hug afterwords.

Thanks,
Matt

OH GRRRR, I can't get the "CODE" tags to work here. I'll post a .txt file. --> http://www.rdi1.com/code.txt


[code]











onClick="countit(this)">


This free script provided by
JavaScript
Kit







[/code]
Reply with Quote Reply
Dec 14th 2002#82179 Report
Member since: Mar 24th 2002
Posts: 3114
Damn.. I'd love to help, but I just returned from a field trip to the bar, and I'm pretty much drunk.. :D

I'd say that instead of using the "formcontent.length", you should count the spaces in the input value.

This could be done with regExp, either in JS, or PHP, or whatever. :p

In PHP, I'd (with my n00b "skills") put a strchr(" ",$string)...
but I'm sure that it'd just return "true" or "false"... There are probably multiple ways of COUNTING the occurances of the space, but I'll let Joe handle that, because he's at a "party" playing xbox or something, and no beer is involved.. :D:D

And yes, there is a way of doing this client side, as I understand you need to be done... I just haven't got my bible for JS here right now.. I'm sure someone else will know the answer for this....so..anywho, I'm off to bed. Night. :o:D
Reply with Quote Reply
Dec 14th 2002#82209 Report
Member since: Apr 5th 2001
Posts: 2544
ROFL!
Reply with Quote Reply
Dec 14th 2002#82211 Report
Member since: Dec 13th 2001
Posts: 1008
LMAO@paav.

Sorry i can't help mattboy
Reply with Quote Reply
Dec 19th 2002#82822 Report
Member since: Mar 24th 2001
Posts: 3734
Found a "word count" javascript this morning.

http://javascriptkit.com/script/script2/countwords.shtml

If anyone can help me edit this so that it takes the number of words times, say, .25, and output that number as a dollar amount, I will give you a big hug.

Thanks
Reply with Quote Reply
Dec 30th 2002#83699 Report
Member since: Dec 30th 2002
Posts: 4
here ya go:
-------
var formcontent=document.wordcount.wordcount2.value
formcontent=formcontent.split(" ")
document.wordcount.wordcount3.value="$" + formcontent.length * .25
--------
all i changed was the last line (which probably wraps over onto another line) i don't exactly know what you mean by dollar amount but i assumed you meant put a $ symbol in front of the result.
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum