So today I have no inspiration to write anything, partly because I'm doing nothing that's interesting today (busy with my homework), and partly I'm exausted just thinking about school tomorrow...
Now, to the Science Fair: I still didn't actually begin working, even though I already chose a topic. The deadline is at the end of January. I feel there's nothing to rush, because I estimated it only took me at most one week to do all the experiment. Going through my files on my laptop, I stumbled upon my science fair project last year, which happened to be just a simple word counter with html coding. It really took me quite a bit of time on this, even with some very helpful online resources, so I think maybe it's good to share this and it may help somebody would be able to help somebody like me last year.
- <html>
- <head>
- <title>Text Analysis</title>
- <style type="text/css">
- textarea {resize:none;
- overflow-y:scroll;
- overflow-x:hidden;}
- </style>
- <script type="text/javascript">
- function myFunction ()
- {
- var formcontent=document.wordcount.wordcount2.value
- formcontent=formcontent.split(" ")
- document.wordcount.wordcount3.value=formcontent.length
- }
- function myFunction2 ()
- {
- var formcontent=document.wordcount.wordcount2.value
- var formcontent=formcontent.replace("...", ".")
- .replace("?", ".")
- .replace("!", ".")
- .split(".");
- document.wordcount.wordcount4.value=formcontent.length
- }
- function myFunction3 ()
- {
- var formcontent=document.wordcount.wordcount2.value
- var formcontent=formcontent.split(" ").join("")
- document.wordcount.wordcount5.value=formcontent.length
- }
- </script>
- </head>
- <body>
- <form name=wordcount><b>Paste the document in the text area below:</b> <br>
- <textarea name="wordcount2" rows=20 cols=75 wrap="on"></textarea> <br>
- <input type="button" value="Analyze"
- onclick="myFunction();myFunction2();myFunction3();"> <br><br><br>
- <table border="1">
- <tr>
- <td>Number of words containing in the text</td>
- <td><input type="text" name="wordcount3" size=5 readonly></td>
- </tr>
- <tr>
- <td>Number of sentences containing in the text</td>
- <td><input type="text" name="wordcount4" size=5 readonly></td>
- </tr>
- <tr>
- <td>Number of characters (w/o spaces) containting in the text </td>
- <td><input type="text" name="wordcount5" size=5 readonly></td>
- </tr>
- </table>
- </body>
- </html>
No comments:
Post a Comment