• We just launched and are currently in beta. Join us as we build and grow the community.

How To Make Word Count Using HTML JavaScript

bambeero

Threat Intelligence Analyst
Divine
B Rep
0
0
0
Rep
0
B Vouches
0
0
0
Vouches
0
Posts
110
Likes
56
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Through this script ,words in paragraphs ,data ,and even whole articles will be counted automatically. How many times did you launch an entire word processor just to find out the number of words of a certain paragraph contains? If you have a site that contains forms, you could also include this script on the page to spare your visitors they had to go through in counting the number of words. You no longer need to waste your time just counting the words a particular site has. This kind of problem can be solve through this tutorial.

In this tutorial we are going to learn How To Make Word Count Using HTML JavaScript.
So, what is it all about?

This is a simple work, but it can help you to your site.

Example:

How To Make Word Count Using HTML JavaScript

*Just click the button name "Calculate" to view the result.
Try to edit the context above. To see the output you desire number of words to see.

Directions:

First: Kindly add this code below to the HEAD section of your page.

  1. <style type=

    "text/css"

    >

  2. .button_calc

    {
  3. background

    :

    buttonface

    ;
  4. width

    :

    100px

    ;
  5. height

    :

    40px

    ;
  6. font-size

    :

    20px

    ;
  7. cursor

    :

    pointer

    ;
  8. }

  9. .result_txt

    {
  10. cursor

    :

    no-drop;
  11. width

    :

    150px

    ;
  12. height

    :

    40px

    ;
  13. text-align

    :

    center

    ;
  14. font-size

    :

    18px

    ;
  15. color

    :

    red

    ;
  16. }

  17. .input_txt

    {
  18. border

    :

    1px

    solid

    red

    ;
  19. font-size

    :

    18px

    ;
  20. }

  21. div {
  22. margin-top

    :

    50px

    ;
  23. border

    :

    1px

    solid

    red

    ;
  24. }

  25. </style>

*This is for css, and you can customize the design.
Second: Kindly copy everything the code below and paste it where you want the script appear.

  1. <form

    method

    =

    "POST"

    name

    =

    "word_count"

    >

  2. <script

    language

    =

    "JavaScript"

    >
  3. function countit(){
  4. var formcontent=document.word_count.word_count2.value
  5. formcontent=formcontent.split(" ")
  6. document.word_count.word_count3.value=formcontent.length
  7. }
  8. </

    script

    >

  9. <table

    border

    =

    "0"

    cellspacing

    =

    "0"

    cellpadding

    =

    "0"

    >
  10. <tr

    >
  11. <td

    width

    =

    "100%"

    >
  12. <textarea

    rows

    =

    "12"

    name

    =

    "word_count2"

    cols

    =

    "60"

    class

    =

    "input_txt"

    wrap=

    "virtual"

    >

    Welcome to Sourcecodester!!! Do you have source code, articles, tutorials, web links, and books to share? You can write your own content here. You can even have your own blog. Submit now.</

    textarea

    >
  13. </

    td

    >
  14. </

    tr

    >
  15. <tr

    >
  16. <td

    width

    =

    "100%"

    >
  17. <div

    align

    =

    "left"

    >
  18. <p

    align

    =

    "center"

    >
  19. <input

    type

    =

    "button"

    value

    =

    "Calculate"

    onClick

    =

    "countit()"

    class

    =

    "button_calc"

    /

    >
  20. <input

    type

    =

    "text"

    name

    =

    "word_count3"

    size

    =

    "20"

    class

    =

    "result_txt"

    disabled

    /

    >
  21. </

    p

    >
  22. </

    div

    >
  23. </

    td

    >
  24. </

    tr

    >
  25. </

    table

    >

  26. </

    form

    >

And that's all!!! Just DOWNLOAD the sourcecode, and try it.
Enjoy coding...


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,348

323,357

Top