Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: SV: Character Counter (count all chars in a form).


Message #1 by "Robert Nyman" <robert.nyman@c...> on Sat, 16 Nov 2002 12:18:36 +0100
This will do the trick:

function countChars(){
		var oForm =3D document.forms["countCharForm"];
		var intNoOfChars =3D
oForm.elements["textOne"].value.length +
oForm.elements["textTwo"].value.length +
oForm.elements["textareaText"].value.length;
		if(parseInt(navigator.appVersion, 10) > 4 ||
navigator.appName =3D=3D "Microsoft Internet Explorer")
document.getElementById("noOfChars").innerHTML =3D intNoOfChars;
    }

<form name=3D"countCharForm">
	<input type=3D"text" name=3D"textOne" onKeyUp=3D"countChars()">
	<input type=3D"text" name=3D"textTwo" onKeyUp=3D"countChars()">
	<textarea cols=3D"10" rows=3D"10" name=3D"textareaText"
onKeyUp=3D"countChars()"></textarea>
</form>


/Robert


-----Ursprungligt meddelande-----
Fr=E5n: Bowman Charles [mailto:Charles.Bowman@O...]
Skickat: den 15 november 2002 17:48
Till: javascript
=C4mne: [javascript] Character Counter (count all chars in a form).



I am trying to count all characters in a form.
Using events ('onChange' & 'onBlur' to update the counter constantly).

There are only three inputs that need counting:
- 2 x <INPUT TYPE=3D"text">
- 1 x <TEXTAREA>

Can anyone advise or point me towards a good sample script?

Many Thanks,
Charles


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D
This electronic message contains information from the mmO2 plc Group
which may be privileged or confidential. The information is intended to
be
for the use of the individual(s) or entity named above. If you are not
the
intended recipient be aware that any disclosure, copying, distribution
or
use of the contents of this information is prohibited. If you have
received
this electronic message in error, please notify us by telephone or email

(to the numbers or address above) immediately.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D





  Return to Index