Guest User

Untitled

a guest
May 7th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Calorie Count</title>
  5. </head>
  6. <body >
  7. <div id="home">
  8. <h1>Kilo</h1>
  9. <h2>New Entry</h2>
  10. <form method="post">
  11. <ul>
  12. <li><input type="text" placeholder="Food" name="food" id="food" required></li>
  13. <li><input type="text" placeholder="Calories" name="calories" id="calories" required></li>
  14. <li><input type="submit" id="submit" value="Save" /></li>
  15. <li><input type="submit" id="show" value="Show" /></li>
  16. </ul>
  17. </form>
  18. </div>
  19. <script>
  20. var link = document.getElementById("submit");
  21. var tes = document.getElementById("show");
  22. link.addEventListener('click', function () {
  23. localStorage.setItem('food', food.value);
  24. localStorage.setItem('calories', calories.value);
  25. }, false);
  26. tes.addEventListener('click', function tes(){
  27. console.log(localStorage.getItem("food")+ " " +localStorage.getItem("calories"));
  28. localStorage.clear();
  29. }, false);
  30. </script>
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment