I'm currently working on HTML code for a view cart page where I display an item name. My goal is to be able to transfer this data, along with others later on, to a different HTML page that will automatically generate a list of multiple items with prices and calculate the total price.
<div class="product-name-options">
<!--START: itemnamelink--><a id="itemName" href="product.asp?itemid=[ITEM_CATALOGID]">[ITEM_NAME]</a><!--END: itemnamelink-->
<button type="button" onclick="window.location='Quote_ep_78-1.html'" id="vc_ChkButton" class="btn"><i class="icon-basket"></i> Get Quote</button>
</div>
On the cart page, I have the following JSON code.
<script>
jQuery( document ).ready(function($) {
var itemName = document.getElementById('itemName');
if(typeof(Storage)!=="undefined")
{
var me = {name: itemName};
localStorage.setItem("user",JSON.stringify(me));
}
else
{
// Sorry! No Web Storage support..
}
});
</script>
Here's the quote page code.
<script>
jQuery( document ).ready(function($) {
console.log(localStorage.getItem("user"));
});
/*document.write("Quantity = " + localStorage.getItem("user") + "<br>");*/
</script>
<div id="add">
</div>
</head>
<body>
<div id = ".myDivClass">
</div>
</body>
I'm running into issues displaying the JSON data in the div I created. Currently, my console.log command outputs "{"name":{}}", which I believe reflects the number of items in my cart but I am unable to display anything else. This is my first time working with JSON so I am struggling a bit, but I am eager to learn and expand on this so I can effectively print out multiple items on the page.