Counting the Words in a Text String : String : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » String »

 

Counting the Words in a Text String



<html>
<body>
<SCRIPT LANGUAGE="JavaScript1.2">
function countWords(str){ 
   var count = 0
   var words = str.split(" ")
    for (i=; i < words.length ; i++){ 
       if (words[i!= ""
          count += 1
    
   document.theForm.results.value = "There are " + count + " words in the text string you entered!"

</script>
</body>
</html>
           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» String