I would like to create an array of users[id,name]
31, Bob Smith
22, Rac Meda
301, Bill burns
With this array I need to be able to:
- Add an item to the array
- Given a name, determine if the name is in the array
- Given a textarea with the 3 names, when a user modifies the text area validate that the 3 names are still in the textarea. If not, remove the name from the array.
Suggestions? Thanks
As for the
<textarea>you can split the input’s value at the end of each line, then loop through each line and split it by', '(a comma and a space).HTML
JavaScript
Here is a jsfiddle of the above code: http://jsfiddle.net/Xq2qc/1/
NOTE: This code does not handle complex user interactions where the user may not use the exact syntax when adding/removing users from the textbox; I’ll leave that up to you to figure out.