Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

sopham / todolist

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • todolist
  • function1.js
Find file
BlameHistoryPermalink
  • sopham's avatar
    new commit · d64191cf
    sopham committed 6 years ago
    d64191cf
function1.js 659 Bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
//add user input to database
$("#addAction").submit(function(event) {
  event.preventDefault();	    
  var task = $("#add-task").val();	 
  $.ajax({
    url: "insert.php",
    type:"POST",
    data:{
      "task": task },
    success: function() {
      $("#add-task").val("");
    }
  });
});

//enter to add to list
var input = document.getElementById("add-task");
input.addEventListener("keyup", function(event) {
  if (event.keyCode === 13) {
    event.preventDefault();
    document.getElementById("add").click();
  }
});

//delete all from database
$("#delete-button").click(function() {
  $.ajax({
    url: "delete-all.php",
    type: "POST"
  });
});