Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. *** Page 1
  2. <!-- Kevin Niland -->
  3. <!-- Web Storage using JSON -->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <title>Web Storage using JSON 1</title>
  8. </head>
  9. <body>
  10. <a href = "Web Storage using JSON 2.html">Link 1</a>
  11. <script>
  12. function cars(type, model, color)
  13. {
  14. this.type = type;
  15. this.model = model;
  16. this.color = color;
  17. }
  18.  
  19. var carOne = new cars("Honda", "Civic", "White");
  20. var carTwo = new cars("Fiat", "Uno", "Red");
  21. var carThree = new cars("Toyota", "RAV4", "Green");
  22. var carFour = new cars("Nissan", "Tarrano", "Blue");
  23.  
  24. var carArray = [carOne, carTwo, carThree, carFour];
  25.  
  26. localStorage.item1 = JSON.stringify(carArray);
  27. </script>
  28. </body>
  29. </html>
  30.  
  31.  
  32. *** Page 2
  33. <!-- Kevin Niland -->
  34. <!-- Web Storage using JSON -->
  35. <!DOCTYPE html>
  36. <html>
  37. <head>
  38. <title>Web Storage using JSON 2</title>
  39. </head>
  40. <body>
  41. <a href = "Web Storage using JSON.html">Link 2</a>
  42.  
  43. <!-- <p>
  44. <button onclick = "carOne()" type = "button">Car 1</button>
  45. <button onclick = "carTwo()" type = "button">Car 2</button>
  46. <button onclick = "carThree()" type = "button">Car 3</button>
  47. <button onclick = "carFour()" type = "button">Car 4</button>
  48. </p> -->
  49. <!-- <button onclick = "displayArray()" type = "button">Display Array</button> -->
  50. <br>
  51. Car Manufacturer: <input type = "text" name = "manufacturer"><br>
  52. Car Model: <input type = "text" name = "model"><br>
  53. Car Color: <input type = "text" name = "color"><br>
  54.  
  55. <p><button onclick = "carOne()" type = "button">Save to local storage</button></p>
  56.  
  57. <p id = "car_1"></p>
  58. <p id = "car_2"></p>
  59. <p id = "car_3"></p>
  60. <p id = "car_4"></p>
  61.  
  62. <!-- <script>
  63. function carOne()
  64. {
  65. var car1R = JSON.parse(localStorage.item1);
  66. document.getElementById("car_1").innerHTML = car1R.type;
  67. document.getElementById("car_2").innerHTML = car1R.model;
  68. document.getElementById("car_3").innerHTML = car1R.color;
  69. }
  70.  
  71. function carTwo()
  72. {
  73. var car2R = JSON.parse(localStorage.item2);
  74. document.getElementById("car_1").innerHTML = car2R.type;
  75. document.getElementById("car_2").innerHTML = car2R.model;
  76. document.getElementById("car_3").innerHTML = car2R.color;
  77. }
  78.  
  79. function carThree()
  80. {
  81. var car3R = JSON.parse(localStorage.item3);
  82. document.getElementById("car_1").innerHTML = car3R.type;
  83. document.getElementById("car_2").innerHTML = car3R.model;
  84. document.getElementById("car_3").innerHTML = car3R.color;
  85. }
  86.  
  87. function carFour()
  88. {
  89. var car4R = JSON.parse(localStorage.item4);
  90. document.getElementById("car_1").innerHTML = car4R.type;
  91. document.getElementById("car_2").innerHTML = car4R.model;
  92. document.getElementById("car_3").innerHTML = car4R.color;
  93. }
  94. </script> -->
  95. <!-- <script>
  96. function displayArray()
  97. {
  98. var cars_Array = JSON.parse(localStorage.item1);
  99. document.getElementById("car_1").innerHTML = cars_Array[0].type;
  100. }
  101. </script> -->
  102. <script>
  103.  
  104. </body>
  105. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement