<script type="text/javascript"> >>> document.addEventListener("DOMContentLoaded", function (event) { >>> if (!navigator.onLine) { >>> var theDropDown = document.getElementById("myDropDown"); >>> var customers = JSON.parse(localStorage["Customers"]); >>> for (var i = 0 ; i < customers.length; i++) { >>> var option = document.createElement('option'); >>> option.text = option.value = customers[i].Name; >>> theDropDown.add(option, 0); >>> } >>> } else { >>> // Either make call to WebApi on the server for the data >>> // Or assume the page was loaded from ASP.NET and the select is already populated. >>> } >>> }); >>> </script>(Assuming a 'select' element in the markup with id="myDropDown" and that you are sure the data is in local storage)
>>{"Table":[{"BUILDING":"MAIN-LV1 ","BLD_DESCR":"MAIN-LV1 Main Building "},{"BUILDING":"WWTP-LV ","BLD_DESCR":"WWTP-LV WASTE WATER TREATMENT PLANT "},{"BUILDING":"ALL-LV ","BLD_DESCR":"ALL-LV ALL "}]} >>>>
>> var buildings = JSON.parse(localStorage["buildings"]); >>>>
[{"BUILDING":"MAIN-LV1 ","BLD_DESCR":"MAIN-LV1 Main Building "},{"BUILDING":"WWTP-LV ","BLD_DESCR":"WWTP-LV WASTE WATER TREATMENT PLANT "},{"BUILDING":"ALL-LV ","BLD_DESCR":"ALL-LV ALL "}]Now the object/var 'buildings' has a length of greater than zero. And I am beginning to see the light.