Basically:
I have a page with a textbox, and a
<ul>
list below it. The<ul>
is populated by a list of the user's friends.The user begins typing in the name of a friend in the textbox, e.g pressing 'r'
I want to immediately update the
<ul>
with each keypress to show only those friends whose names begin with R, e.g 'Richard, Redmond, Raheem', etc.As the user types more, I want to further restrict the names, e.g if user types 'Ri' then I only want 'Richard' in the list.
I'm looking for ideas on how to implement the searching. Specifically, if I should use an Array or JSON class for storing the list of friends, if there's any regular expression I should use, etc?
Also which jQuery event should I use for listening to the keypress events?
` to a table, or put the names inside a hyperlink, it would break this code. Putting the names externally in javascript seems better. Also the javascript is responsible for populating the `
– Ali Apr 16 '11 at 16:53` in the first place.