-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddemployee.html
111 lines (105 loc) · 4.71 KB
/
addemployee.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
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://getbootstrap.com/docs/5.3/assets/css/docs.css" rel="stylesheet">
<title>Students Information System</title>
<style>
body {
background-color: #f8f9fa; /* Light gray */
}
.navbar {
background-color: #5682ad; /* Dark gray */
}
.container {
background-color: white;
padding: 20px;
border-radius: 10px;
margin-top: 20px;
}
.btn-primary {
background-color: #3a79b8; /* Dark gray */
border-color: #3277bd; /* Dark gray */
}
.btn-primary:hover {
background-color: #377abd; /* Dark gray */
border-color: #5586b8; /* Dark gray */
}
</style>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<a class="navbar-brand text-white" href="menubar.html">Students Information System</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active text-white" aria-current="page" href="viewallemployees.html">View Studnet</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="addemployee.html">Add Student</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="searchbyid.html">Search Studnet</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="deletebyid.html">Remove Student</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="updateemployee.html">Update details</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<h2>Add Student</h2>
<form id="employeeForm">
<div class="mb-3">
<label for="postId" class="form-label">Student ID:</label>
<input type="text" class="form-control" id="postId" name="id">
</div>
<div class="mb-3">
<label for="postFirstName" class="form-label">First Name:</label>
<input type="text" class="form-control" id="postFirstName" name="firstname">
</div>
<div class="mb-3">
<label for="postLastName" class="form-label">Last Name:</label>
<input type="text" class="form-control" id="postLastName" name="lastname">
</div>
<div class="mb-3">
<label for="postAge" class="form-label">Age:</label>
<input type="number" class="form-control" id="postAge" name="age">
</div>
<button type="button" class="btn btn-primary">Submit</button>
<div id="output" class="mt-3"></div>
</form>
</div>
<script>
const apiBaseUrl = 'https://j6vbwe5ntf.execute-api.us-east-1.amazonaws.com/stage1';
document.querySelector('form button').addEventListener('click', postEmployee);
async function postEmployee() {
const id = document.getElementById('postId').value;
const firstName = document.getElementById('postFirstName').value;
const lastName = document.getElementById('postLastName').value;
const age = document.getElementById('postAge').value;
try {
const response = await axios.post(apiBaseUrl, {
id: id,
firstname: firstName,
lastname: lastName,
age: age
});
document.getElementById('output').innerText = 'Student added successfully';
} catch (error) {
document.getElementById('output').innerText = 'Failed to add Student';
}
}
</script>
</body>
</html>