How To Make Word Count Using HTML JavaScript
Submitted by alpha_luna on Friday, May 29, 2015 - 00:01.
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.
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.
*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.
And that's all!!! Just DOWNLOAD the sourcecode, and try it.
Enjoy coding...
Example:
Directions:
First: Kindly add this code below to the HEAD section of your page.- <style type="text/css">
- .button_calc {
- background:buttonface;
- width: 100px;
- height: 40px;
- font-size: 20px;
- cursor:pointer;
- }
- .result_txt {
- cursor:no-drop;
- width:150px;
- height:40px;
- text-align:center;
- font-size:18px;
- color:red;
- }
- .input_txt {
- border:1px solid red;
- font-size:18px;
- }
- div {
- margin-top:50px;
- border:1px solid red;
- }
- </style>
- <form method="POST" name="word_count">
- <script language="JavaScript">
- function countit(){
- var formcontent=document.word_count.word_count2.value
- formcontent=formcontent.split(" ")
- document.word_count.word_count3.value=formcontent.length
- }
- </script>
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="100%">
- </td>
- </tr>
- <tr>
- <td width="100%">
- <div align="left">
- <p align="center">
- <input type="button" value="Calculate" onClick="countit()" class="button_calc" />
- <input type="text" name="word_count3" size="20" class="result_txt" disabled />
- </p>
- </div>
- </td>
- </tr>
- </table>
- </form>
Add new comment
- 84 views