Count Words
<HTML> <HEAD> <SCRIPT> function countWords(str){ var count = 0; words = str.split(" "); for (i=0 ; i < words.length ; i++){ if (words[i] != "") count += 1; } document.theForm.results.value = count; } </SCRIPT> </HEAD> <BODY> <FORM name="theForm"> Enter a text string: <TEXTAREA name=inStr rows=5 cols=90> </TEXTAREA> <INPUT type=button value="Count Words" onClick="countWords(document.theForm.inStr.value)";> <INPUT type=button value="Clear" onClick='document.theForm.inStr.value=""';> <TEXTAREA name=results rows=5 cols=90> </TEXTAREA> </FORM> </BODY> </HTML>