May 24, 2012, 08:33:26 AM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Mobile users - Our forum is Tapatalk enabled.
http://www.tapatalk.com/
Home
Help
Search
Login
Register
DotDragnet
>
The Tech Side
>
Tech stuff
>
Simple javascript character counter
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Simple javascript character counter (Read 291 times)
Steve Lampkins
Hero Member
Posts: 1327
OOH! *TITTER*
Simple javascript character counter
«
on:
November 24, 2011, 11:20:13 AM »
I have a very simple set of forms that you can use to count the number of characters you enter.
Works well, but I'd rather it were dynamic, so I don't have to click a button.
Also, wrapping a div around the forms, to try and get a background colour (CSS-styled), breaks the first form. No idea why.
EDIT: fixed that, I wasn't properly closing my styling mark up in the div
Any help? Want to keep it simple.
<script language="JavaScript">
function countit(what){
formcontent=what.form.charcount.value
what.form.displaycount.value=formcontent.length
}
</script>
Then three of these in a row:
<form method="POST">
<input type="text" name="charcount" size="75" style="font-family: Courier New; font-size: 10pt;">
<input type="button" onClick="countit(this)" value="Count" style="font-weight:bold; font-size: 10pt;">
<input type="text" name="displaycount" size="3" style="font-weight:bold; font-size: 10pt; text-align:center;">
</form>
«
Last Edit: November 24, 2011, 11:29:17 AM by Steve Lampkins
»
Logged
JasonD
Global Moderator
Hero Member
Posts: 551
Re: Simple javascript character counter
«
Reply #1 on:
November 24, 2011, 11:34:10 AM »
<input type="text" name="charcount" onkeyup="countit(this)" onchange="countit(this)" ...
Logged
Steve Lampkins
Hero Member
Posts: 1327
OOH! *TITTER*
Re: Simple javascript character counter
«
Reply #2 on:
November 24, 2011, 11:55:27 AM »
Couldn't get much simpler than that.
Thanks a bunch!!
Logged
Dom
Hero Member
Posts: 1681
Taster of pasities. Clanger of both pots AND pans.
Re: Simple javascript character counter
«
Reply #3 on:
November 25, 2011, 10:02:54 AM »
I built a character counter a while ago but I don't think it was as simple as this one. I shall thus steal it, and use it as if it were my own!
#CowboyDeveloper
Logged
Sig edited due to lolling at this
http://img72.imageshack.us/img72/6069/mainphpg2viewcoreh.gif
Steve Lampkins
Hero Member
Posts: 1327
OOH! *TITTER*
Re: Simple javascript character counter
«
Reply #4 on:
November 25, 2011, 01:07:14 PM »
I'm sure everyone already knows you are simple.
Logged
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
=> Jee's Forum of Appalling Jokes
-----------------------------
The Creative Side
-----------------------------
=> Arty stuff
=> Photography
=> On the web
-----------------------------
The Tech Side
-----------------------------
=> Tech stuff
=> Hardware & Software
-----------------------------
The Business Side
-----------------------------
=> Anything business related
-----------------------------
The Practical Side
-----------------------------
=> Practical Advice
DotDragnet
>
The Tech Side
>
Tech stuff
>
Simple javascript character counter
Loading...