|
-
Jul 6th, 2001, 01:29 PM
#1
Thread Starter
Hyperactive Member
textarea counter
I want a textarea field and a counter that lets the user know how many characters he has typed in. I tried something like
<Script Language="JavaScript">
function adding()
{
texto = new String()
texto = document.Rform.Rtext.value
document.Rform.displayChars.value = texto.lenght
}
</Script>
</head>
<body>
<form name="Rform">
<textarea name="Rtext" cols=10 rows=20 onChange="adding()"></textarea>
<BR><BR>
<input type="text" size=5 name="displayChars">
But it doesnt work. Any ideas people?
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Jul 6th, 2001, 01:44 PM
#2
Code:
function calcCharLeft(f) {
clipped = false
maxLength = 1000
if (f.message.value.length > maxLength) {
f.message.value = f.message.value.substring(0,maxLength)
charleft = 0
clipped = true
} else {
charleft = maxLength - f.message.value.length
}
f.msgCL.value = charleft
return clipped
}
and
<input value="1000" size="3" name="msgCL" disabled>
message is the name for the textarea you type into, but I don't think it works in NS4.x
also I noticed you spelled length wrong in your script, change that and see if it works.
-
Jul 6th, 2001, 02:44 PM
#3
lookd correc except that your mispelled length. Is that how it is in your actual code?
-
Jul 7th, 2001, 09:44 PM
#4
Thread Starter
Hyperactive Member
Oops!!! Looks like I meesed up good didn't I? But after I changed the typo it still wont work right. I mean, it will show the number of characters if I click on somewhere else on the page but not as I am typing them in. Is it possible to do this?
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Jul 8th, 2001, 03:44 PM
#5
tha tfunction I left does exactly that.
-
Jul 8th, 2001, 10:47 PM
#6
Thread Starter
Hyperactive Member
OK Thanks a lot guys. you been very helpful. Have a nice day.
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|