I've three input fields to "search" a JSON tree. If all three fields are filled and correct get the data from next JSON level.
I count up a number through the keyup-event to get next data of a JSON tree. But every time all three fields are filled the counter will reseted.
HTML
<h1>sein</h1>
<form>
<input type="text" id=simple_present placeholder="simple present">
<input type="text" id=simple_past placeholder="simple past">
<input type="text" id=past_participle placeholder="past participle">
</form>
<div class="answer">Enter: be - was - been</div>
JS
$('input').on('keyup', function() {
var count = 0;
if (this.value === json.verbs.irregular[count++][this.id]) {
$(this).prop('disabled', true).next().focus();
}
if ($('input:not(:disabled)').length === 0) {
$('input').val('').prop('disabled', false).first().focus();
$('h1').text(json.verbs.irregular[count++].infinitiv);
alert(count);
}
});
Perhaps the variable will set to 0 on each key-event? But I cant set it outside the keyup
-event!
Here is a demonstration of what I've done so far.
Just type:
- be
- was
- been
Any ideas?