-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathform_data.js
25 lines (22 loc) · 969 Bytes
/
form_data.js
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
jQuery(document).on('ready', function() {
jQuery('form#add-new-task').bind('submit', function(event){
event.preventDefault();
var form = this;
var json = ConvertFormToJSON(form);
var tbody = jQuery('#to-do-list > tbody');
$.ajax({
type: "POST",
url: "submit.php",
data: json,
dataType: "json"
}).done(function() {
tbody.append('<tr><th scope="row" style="background-color:' + form['new-task-color'].value +
'"><input type="checkbox" /></th><td>' + form['new-task-date'].value +
'</td><td>' + form['new-task-priority'].value + '</td><td>' + form['new-task-name'].value +
'</td><td>' + form['new-task-desc'].value + '</td><td>' + form['new-task-email'].value + '</td></tr>');
}).fail(function() {
alert("Failed to add to-do");
});
return true;
});
});