After appending a row to a table on the HTML, How to take all the data (in JSON format) and store in local storage?
This is my JS code:
// Our next step is to check if we have something on local storage already saved
// in our machine and if we do we need to place that in the page
$("#div1").hide();
if(localStorage.getItem('dataToStore')) {
//String to JSON object
var exidata= JSON.parse(localStorage.getItem('dataToStore'));
$('#details tr:last').after('<tr>');
$.each(exidata, function(key, value){
$('#details tr:last').append('<td>'+value+'</td>');
});
$('#details tr:last').after('</tr>');
} else{
alert('Problem mate, its empty!!');
}
});
Upon loading the page it checks if there is anything in localstorage, if so it prints it out in a table. The next step would be to switch over to the registration form, fill in the details and then click submit, which then adds the details to the table. So you now have n+1 rows. I then want to take all the data (JSON format)and store it in the local storage.
Apologies if the problem/question is not clear.
Many thanks