-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.html
99 lines (94 loc) · 3.46 KB
/
form.html
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/ionic.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/geturi.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var id = decodeURI(getUrlVars()["id"]);
var title = decodeURI(getUrlVars()["title"]);
var duration = decodeURI(getUrlVars()["duration"]);
var price = decodeURI(getUrlVars()["price"]);
$("#id").val(id);
$("#title").val(title);
$("#duration").val(duration);
$("#price").val(price);
$("#update").click(function() {
var id = $("#id").val();
var title = $("#title").val();
var duration = $("#duration").val();
var price = $("#price").val();
var dataString = "id=" + id + "&title=" + title + "&duration=" + duration + "&price=" + price + "&update=";
$.ajax({
type: "POST",
url: "http://localhost/phonegap/crud/www/php/update.php",
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function() {
$("#update").val('Connecting...');
},
success: function(data) {
if (data == "success") {
alert("Updated");
$("#update").val("Update");
} else if (data == "error") {
alert("error");
}
}
});
});
$("#delete").click(function() {
var id = $("#id").val();
var dataString = "id=" + id + "&delete=";
$.ajax({
type: "GET",
url: "http://localhost/phonegap/crud/www/php/delete.php",
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function() {
$("#delete").val('Connecting...');
},
success: function(data) {
if (data == "success") {
alert("Deleted");
$("#delete").val("Delete");
} else if (data == "error") {
alert("error");
}
}
});
});
});
</script>
</head>
<body>
<div class="bar bar-header bar-positive" style="margin-bottom:80px;background-color: blue">
<a href="index.html" class="button button-clear">Home</a>
<h1 class="title">Update Database</h1>
<a class="button button-clear" href="readjson.html">Read Data</a>
</div>
<br/>
<br/>
<div class="list">
<input type="hidden" id="id" value="" />
<div class="item">
<label>Employee Name</label>
<input type="text" id="title" value="" />
</div>
<div class="item">
<label>Employee Position</label>
<input type="text" id="duration" value="" />
</div>
<div class="item">
<label>Employee Salary</label>
<input type="text" id="price" value="" />
</div>
<div class="item">
<input type="button" id="update" class="button button-block" value="Update" />
<input type="button" id="delete" class="button button-block" value="Delete" />
</div>
</div>
</body>
</html>