-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_addhospital.html
79 lines (69 loc) · 3.44 KB
/
admin_addhospital.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
<!DOCTYPE html>
<html>
<head>
<title>Add hospital</title>
<link rel="stylesheet" href="css\style14.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="split left">
<div class="userimg" >
<img src="other/avatar.png" style="width: 45%; height:60% ;padding: 15px; background-size: cover; border-radius: 110px;">
</div>
<div class="navbar">
<button class="btn" style="background-color: white;" onclick="window.location.href='admin_addhospital.html'">Add Hospital</button>
<button class="btn" onclick="window.location.href='admin_approvefeedback.html'">Feebacks</button>
<button class="btn" onclick="window.location.href='admin_add.html'">Add Medicines | Operations | Tests</button>
<button class="btn" onclick="window.location.href='admin_check.html'">Check Medicines | Operations | Tests</button>
</div>
</div>
<div class="split right">
<div class="header">Add another Hospital</div>
<div class="card">
<form class="cardform"action="#">
<input type="text" id="name" class="box" placeholder="Enter hospital name..">
<input type="text" id="specialization" class="box" placeholder="Enter specialization of hospital..">
<input type="text" id="address" class="box" placeholder="Enter address of hospital">
<input type="text" id="number" class="box" placeholder="Phone Number">
<button onclick="submitDetails()" class="submitbox" >Submit</button>
</form>
</div>
<h2 id="error" style="margin-left: 200px; color: red;"></h2>
</div>
<script>
function submitDetails(){
let name = document.getElementById("name").value
let specialization = document.getElementById("specialization").value
let address = document.getElementById("address").value
let number = document.getElementById("number").value
if(name == "" || specialization == "" || address == "" || number == "")
document.getElementById("error").innerHTML = "Fields Missing!!"
else{
var myHeaders = new Headers();
myHeaders.append("Authorization", `Token ${localStorage.getItem('token')}`);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"name": name,
"specialization": specialization,
"address": address,
"phone_number": number
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://localhost:8000/hospitaldatabaseview/", requestOptions)
.then(response => response.text())
.then((result) => {
document.getElementById("error").innerHTML = "Hospital Added Successfully!!"
})
.catch((error) => {
document.getElementById("error").innerHTML = "There was some error"
});
}
}
</script>
</body>
</html>