Last active
April 25, 2017 19:12
-
-
Save ezesundayeze/a7b683a7448f8ee53aadd5ffc226a108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveTask(e){ | |
//get form values | |
var taskName = document.getElementById(“taskName”).value; | |
var taskDescription = document.getElementById(“taskDescription”).value; | |
//create an object to store the variables | |
var tasks = { | |
name:taskName, | |
description:taskDescription | |
} | |
if(localStroage.getItem(‘tasks’)==null){ | |
var task =[]; task.push(tasks); | |
localStorage.SetItem('task',JSON.stringyfy(task)); | |
}else{ | |
var myTask = localStorage.getItem('task',JSON.parse(task)); myTask.push(task); | |
// then reset the localStorage | |
localStorage.setItem('task',JSON.stringify(myTask)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment