I have a number of drivers saved in objects:
function Driver(draw, name) {
this.draw = draw;
this.name = name;
}
Now, the number of drivers could change depending on how my form is used. It could be 5, it could be 60.
My understanding of using HTML5 Session storage is the syntax goes like this:
sessionStorage.setItem('name', value).
What I would like to do is have the ability to save them with the names driver1, driver2, driver, 3, etc. But, the numbers won't be consecutive and may include any amount up to 60.
Here's how I tried to do it, but it isn't working.
$('.print').click(function () {
for (var i = 0; i < 60; i++){
var name3 = "."+"driver"+i;
if (typeof Driver[name3] != "undefined") {
console.log(name3);
console.log(Driver[name3]);
sessionStorage.setItem(Driver[name3], JSON.stringify(Driver[name3]));
console.log(sessionStorage.getItem(Driver[name3]));
entries[entries.length] = name3;
}
console.log(entries);
sessionStorage.setItem('entries', JSON.stringify(entries));
};
What I tried to do is set a value for var name3, and then set the name of the session storage file to that value. It's pretty obvious to me I can't do that. I can't figure out another way of achieving my goal?
FYI, my attempt to sessionStorage 'Entries' is working perfectly.
Here's my entire project if you need to fiddle with it: http://precisioncomputerservices.com/slideways/index.html