Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Calorie Count</title>
- </head>
- <body >
- <div id="home">
- <h1>Kilo</h1>
- <h2>New Entry</h2>
- <form method="post">
- <ul>
- <li><input type="text" placeholder="Food" name="food" id="food" required></li>
- <li><input type="text" placeholder="Calories" name="calories" id="calories" required></li>
- <li><input type="submit" id="submit" value="Save" /></li>
- <li><input type="submit" id="show" value="Show" /></li>
- </ul>
- </form>
- </div>
- <script>
- var link = document.getElementById("submit");
- var tes = document.getElementById("show");
- link.addEventListener('click', function () {
- localStorage.setItem('food', food.value);
- localStorage.setItem('calories', calories.value);
- }, false);
- tes.addEventListener('click', function tes(){
- console.log(localStorage.getItem("food")+ " " +localStorage.getItem("calories"));
- localStorage.clear();
- }, false);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment