-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.html
86 lines (73 loc) · 2.67 KB
/
add.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Star Wars - Express</title>
<!-- Latest compiled and minified CSS & JS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>Star Wars Express</h1>
<h3>The greatest resource in the galaxy for Star Wars statistics!</h3>
<hr>
<a href="/"><button class="btn btn-danger btn-lg"><span class="fa fa-eye"></span> View Characters</button></a>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><strong>Add Characters</strong></h3>
</div>
<div class="card-body">
<form method="POST" role="form">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name">
</div>
<div class="form-group">
<label for="role">Role</label>
<input type="text" class="form-control" id="role">
</div>
<div class="form-group">
<label for="age">Age</label>
<input type="text" class="form-control" id="age">
</div>
<div class="form-group">
<label for="force-points">Force Points</label>
<input type="text" class="form-control" id="force-points">
</div>
</form>
<br>
<div class="text-right">
<button type="submit" class="btn btn-primary btn-md" id="add-btn"><span class="fa fa-fire"></span> Add to the Force</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
// Question: What does this code do?
$("#add-btn").on("click", function(event) {
event.preventDefault();
var newCharacter = {
name: $("#name").val().trim(),
role: $("#role").val().trim(),
age: $("#age").val().trim(),
forcePoints: $("#force-points").val().trim()
};
// Question: What does this code do??
$.post("/api/characters", newCharacter)
.then(function(data) {
console.log("add.html", data);
alert("Adding character...");
});
});
</script>
</body>
</html>