I would like to store the yes value in localStorage with movie1 key using javascript. However, I want the key part 1 be dynamic, based on what movieID set movieID .
yes
movie1
1
movieID
This is what I have now, but it does not work:
movieID = 1; localStorage.movie + movieID = 'yes';
Any thoughts or insights on how I can do this will be greatly appreciated. Thanks!
Try the following:
localStorage['movie'+movieID] = 'yes';
You can use the setItem function to store values ββin local storage:
localStorage.setItem('movie' + movieID, 'yes');
Then, when you want to check the value, you can use
localStorage.getItem('movie' + movieID);
http://jsfiddle.net/ZwhBY/
Mark the square brackets for the properties.
http://www.jibbering.com/faq/faq_notes/square_brackets.html
I think,
actually is an assistant in using the library and is not official.