JavaScript:
var array = [
['shoe', 1],
['shirts', 2]
];
$('input#item').keyup(function()
{
var value = $(this).val();
$('#value').html('value from array');
});
HTML:
<input type="text" name="item" id="item" />
<br />
Value: <span id="value"></span>
I want to find the value of the item the user is searching for while he is still typing.
Example:
a) When the user types s, it should output 1, because it’s the first value in the array.
b) When the user types shi, it should output 2, because it matches shirts.
c) If there is no match it should output no match.
Note:
I want to keep the structure of the array, if possible.
why, just loop through the array …
didn’t test it tho