You could use local storage to save the data. It works as easy as this:
localStorage.setItem('key', 'value');
localStorage.getItem('key'); // returns 'value'
You could save the names using an incrementing key:
localStorage.setItem('name-' + (localStorage.length + 1).toString(), 'favName');
// Names stored as 'name-0', 'name1', ...
And then, to retrieve the list:
var names = new Array();
if (localStorage) {
if (localStorage.length) {
for (var i = 0; i < localStorage.length; i++) {
names[i] = localStorage.getItem('name-' + i.toString());
}
} else {
names[0] = 'You have no favorite names stored';
}
}
There are some plugins that provide fallbacks on browsers that don't support web storage (Even on ie6), like totalStorage or jstorage.