Nbbnnn

by - April 25, 2020

Shopping cart

Shopping List

// Dynamically populate the table with shopping list items. //Step below can be done via PHP and AJAX, too. function doShowAll() { if (CheckBrowser()) { var key = ""; var list = "ItemValue\n"; var i = 0; //For a more advanced feature, you can set a cap on max items in the cart. for (i = 0; i <= localStorage.length-1; i++) { key = localStorage.key(i); list += "" + key + "\n" + localStorage.getItem(key) + "\n"; } //If no item exists in the cart. if (list == "ItemValue\n") { list += "empty\nempty\n"; } //Bind the data to HTML table. //You can use jQuery, too. document.getElementById('list').innerHTML = list; } else { alert('Cannot save shopping list as your browser does not support HTML 5'); } }

You May Also Like

0 Reviews

featured posts