I have this array
var foods = new Array();
foods = [
{ id: 1, correct:'icecream', display: 'icecream', response: ''},
{ id: 2, correct:'sundae', display: 'sundae', response: ''},
];
and this html div
<div id="showfoods" class="foodlist">
<div <input id="inputFoodChoice"class="foodinput" /></div>
</div>
Here's a jquery portion of what will happen with the form portion of the project
function FoodDisplay()
{
var txtTrial = "";
$("#showfoods").hide();
txtTrial = trials[curTrial].display;
$("#textPrompt").html(txtTrial);
$("#showfoods").show();
$("#inputFoodChoice").val('');
$("#inputFoodChoice").focus();
}
The word "icecream" will appear with a form box below it and what the user will do is enter the exact word, icecream, then press enter (ltr==13)
What I want is to store the value the person types into the empty "response" portion of the foods array, then to compare this with the value of "correct" in the foods array. depending on whether or not the person gets it right, a message will pop up saying you got it! or incorrect!
after that message appears for however long, it will show the word "sundae" in the same manner.
I'm having trouble storing the input value/comparing it with the correct value. Could someone please help?
I guess in a sense I want it to "edit" the response value in foods array, so I can take that value and compare it to the input value, or is that even necessary?