Hello, I am working on a project. I am mostly new with javascript. I have taken a java script class before(was not very helpful).
I am now trying to learn more on my own. I have this spell check program I have been creating.
I am unsure how to loop through my array(wordlist array) and then compare my array to the variable(wordVar), which is entered by the user.
The idea is that if the variable exists in the array then the program will display Correct spelling. If it is wrong I would like to show the correct spelling of the word. However, right now I am more interested in looping through my array and comparing the variable
Here is my javascript and my form:
Code:
<script type="text/javascript">
<!--
//wordlist array declared and populated
var wordlist = new Array(6);
wordlist[0] = "dog";
wordlist[1] = "potato";
wordlist[2] = "napkin";
wordlist[3] = "knife";
wordlist[4] = "pumpkin";
wordlist[5] = "probably";
wordlist[6] = "wednesday";
document.write("Result of array is - "+wordlist[0]);
function readText (form) {
wordVar =form.inputbox.value;
alert ("You Entered: " + wordVar + ". Did you mean " + wordlist[0] + "?" );
//alert(wordlist);
//next loop through wordlist array and compare words somehow. switch input to all lower
}
-->
</script>
The Form
Code:
<form name="myForm">
<P>
<input type="text" name="inputbox" value="">
<input type="button" name="button1" Value="Read" onClick="readText(this.form)">
</p>
</form>