-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecipientForm.html
305 lines (259 loc) · 11.7 KB
/
RecipientForm.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="RecipientForm.css">
<title>Recipient Form - BloodServe</title>
</head>
<body>
<!--Header & Nav Bar-->
<header class="header">
<h1>Blood-Serve</h1>
<ul class="nav-links">
<li><a href="MainPage.html">Home</a></li>
<li><a href="login.html">Login</a></li>
<li><a href="About-Us.html">About Us</a></li>
<li><a href="Blogs.html">Blogs</a></li>
<li><a id="logout-link" class="dropdown-item" href="http://127.0.0.1:5500/login.html">Log-out</a></li>
</ul>
</header>
<!-- Welcome User -->
<div class="welcome-container text-center mt-5 pt-5">
<h2>Welcome User</h2>
</div>
<!-- Main Content -->
<div class="main-content">
<div class="centered-content">
<h1>Recipient Information</h1>
<form id="recipientForm" action="/recipient" method="post">
<div class="mb-3">
<input type="text" class="form-control" name="name" placeholder="Name">
</div>
<div class="mb-3">
<input type="number" class="form-control" name="age" placeholder="Age">
</div>
<div class="mb-3">
<select class="form-select" name="gender" id="gender">
<option value="" disabled selected>Gender</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select>
</div>
<div class="mb-3">
<select class="form-select" name="blood_type">
<option selected disabled>Blood Type</option>
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="AB+">AB+</option>
<option value="AB-">AB-</option>
<option value="O+">O+</option>
<option value="O-">O-</option>
</select>
</div>
<div class="mb-3">
<input type="text" class="form-control" name="contact_info" placeholder="Contact Info">
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
<div id="successMessage" class="d-none mt-3 alert alert-success" role="alert">
Recipient data submitted successfully
</div>
</div>
</div>
<!--Footer-->
<footer class="footer mt-auto py-3 bg-light">
<nav class="text-center">
<ul class="list-inline">
<li class="list-inline-item"><a href="MainPage.html">Home</a></li>
<li class="list-inline-item"><a href="login.html">Login</a></li>
<li class="list-inline-item"><a href="About-Us.html">About Us</a></li>
<li class="list-inline-item"><a href="Blogs.html">Blogs</a></li>
</ul>
</nav>
<div class="text-center">
<p>Credits: Abdul Wahab, Hiba Rizwan, Hafsa Waseem</p>
<p>© 2024 BloodServe. All Rights Reserved.</p>
</div>
</footer>
<script>
document.getElementById('recipientForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting the traditional way
// Create a FormData object to easily access form values
const formData = new FormData(event.target);
// Convert FormData to a JSON object
const formDataJSON = {};
formData.forEach((value, key) => {
formDataJSON[key] = value;
});
// Send the POST request using fetch
fetch('http://localhost:10000/recipient', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formDataJSON)
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
document.getElementById('successMessage').classList.remove('d-none'); // Show success message
return response.json();
})
.then(data => {
console.log('Success:', data);
// Optionally handle success, e.g., display a success message or redirect
})
.catch(error => {
console.error('Error:', error);
// Optionally handle errors, e.g., display an error message
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFyJDd6j2vL6boUs4Ie7KNg6B5owJp2JJ4xCMGiw1FfJIl2x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="js/RecipientSearch.js"></script>
</body>
</html>
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="RecipientForm.css">
<title>Recipient Form - BloodServe</title>
</head>
<body>
<header class="header">
<h1>Blood-Serve</h1>
<ul class="nav-links">
<li><a href="MainPage.html">Home</a></li>
<li><a href="login.html">Login</a></li>
<li><a href="About-Us.html">About Us</a></li>
<li><a href="Blogs.html">Blogs</a></li>
</ul>
</header>
<div class="welcome-container text-center mt-5 pt-5">
<h2>Welcome User</h2>
</div>
<div class="main-content">
<div class="centered-content">
<h1>Recipient Information</h1>
<form id="recipientForm" action="/recipient" method="post">
<div class="mb-3">
<input type="text" class="form-control" name="name" placeholder="Name">
</div>
<div class="mb-3">
<input type="number" class="form-control" name="age" placeholder="Age">
</div>
<div class="mb-3">
<input type="text" class="form-control" name="gender" placeholder="Gender"></input>
this select query is commented <select class="form-select" name="Gender">
<option selected disabled>Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</div>
<div class="mb-3">
<select class="form-select" name="blood_type">
<option selected disabled>Blood Type</option>
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="AB+">AB+</option>
<option value="AB-">AB-</option>
<option value="O+">O+</option>
<option value="O-">O-</option>
</select>
</div>
<div class="mb-3">
<input type="text" class="form-control" name="contact_info" placeholder="Contact Info">
</div>
<button type="submit" class="btn btn-success">Register as Donor</button>
</form>
</div>
</div>
<footer class="footer mt-auto py-3 bg-light">
<nav class="text-center">
<ul class="list-inline">
<li class="list-inline-item"><a href="MainPage.html">Home</a></li>
<li class="list-inline-item"><a href="login.html">Login</a></li>
<li class="list-inline-item"><a href="About-Us.html">About Us</a></li>
<li class="list-inline-item"><a href="Blogs.html">Blogs</a></li>
</ul>
</nav>
<div class="text-center">
<p>Credits: Abdul Wahab, Hiba Rizwan, Hafsa Waseem</p>
<p>© 2024 BloodServe. All Rights Reserved.</p>
</div>
</footer>
-->
<!--
<script>
document.getElementById('recipientForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting the traditional way
// Create a FormData object to easily access form values
const formData = new FormData(event.target);
// Convert FormData to a JSON object
const formDataJSON = {};
formData.forEach((value, key) => {
formDataJSON[key] = value;
});
// Send the POST request using fetch
fetch('http://localhost:10000/recipient', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formDataJSON)
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
// Optionally handle success, e.g., display a success message or redirect
})
.catch(error => {
console.error('Error:', error);
// Optionally handle errors, e.g., display an error message
});
});
</script> -->
<!-- <script>
document.getElementById('recipientForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting the traditional way
// Create a FormData object to easily access form values
const formData = new FormData(event.target);
// Convert FormData to a JSON object
const formDataJSON = {};
formData.forEach((value, key) => {
formDataJSON[key] = value;
});
// Send the POST request using fetch
fetch('http://localhost:10000/recipient', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formDataJSON)
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
// Optionally handle success, e.g., display a success message or redirect
})
.catch(error => {
console.error('Error:', error);
// Optionally handle errors, e.g., display an error message
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFyJDd6j2vL6boUs4Ie7KNg6B5owJp2JJ4xCMGiw1FfJIl2x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="js/RecipientSearch.js"></script>
</body>
</html> -->