High School Math

MISSION STATEMENT: To encourage and promote a greater use of the internet and computer technology in the math classroom. For educators, students, parents and homeschoolers.

Tuesday, November 20, 2007

Text to Morse Code

To Convert Text Only into Morse Code.
1) Copy & Paste the code between the dotted lines into Notepad.
2) Save the program onto your computer as ConvertMorse.html.
3) Left Click on ConvertMorse.html to run the program.
4) Input your Text into the textarea box.
5) Click the Convert To Button and see the answer.
.............................
<script language="javascript" type="text/javascript">
function translate(form) {
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,?:-!";
morse = new Array(
".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..",
"--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-",
"-.--","--..",".-","-...","-.-.","-..",".","..-.","--.","....","..",".---",
"-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",
".--","-..-","-.--","--.."," ",".-.-.-","--..--","..--..","---...","-....-","!");
form.output.value = "";var input = form.input.value;output = "";
for(count = 0; count <input.length; count++){daChar = input.charAt(count);
for (i = 0; i <letters.length; i++){if (daChar == letters.charAt(i)){
output += morse[i];break;}}}form.output.value = output;}</script>
<form><table><tr><td><H3><U>Text to Morse Code Converter</U></H3>Type your text
into box below.<br><textarea name=input cols=30 rows=3></textarea></td></tr><tr><td>
<input type=button value="Convert to Morse Code" onClick="javascript:translate(this.form)">
</td></tr><tr><td><textarea name=output cols=30 rows=3></textarea></td></tr></table></form>
.............................
More Math Stuff at www.TheMathWebSite.com.