-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetails.html
275 lines (238 loc) · 7.53 KB
/
details.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
div {
border: 1px solid #ccc;
padding: 20px;
margin: 20px;
border-radius: 5px;
background-color: #fff;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin: 10px 0;
font-weight: bold;
}
input[type="text"],
input[type="tel"],
input[type="email"],
select,
textarea,
input[type="date"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 5px 0;
}
select {
height: 36px;
}
input[type="checkbox"] {
margin-right: 5px;
}
#chargeAmount {
display: none;
}
/* Optional: Style the submit button if you have one */
input[type="submit"] {
background-color: #007BFF;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
/* Optional: Style the file input */
input[type="file"] {
margin-top: 5px;
}
/* Optional: Style the textarea */
textarea {
width: 100%;
}
.but {
padding: 15px 25px;
border: unset;
border-radius: 15px;
color: #212121;
z-index: 1;
background: #e8e8e8;
position: relative;
font-weight: 1000;
font-size: 17px;
-webkit-box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
transition: all 250ms;
overflow: hidden;
cursor:pointer;
}
.but::before {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 0;
border-radius: 15px;
background-color: #212121;
z-index: -1;
-webkit-box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
transition: all 250ms
}
.but:hover {
color: #e8e8e8;
}
.but:hover::before {
width: 100%;
}
/* Add more styles as needed for your specific design preferences */
</style>
</head>
<body>
<div>
<label>Book details:</label>
<br>
<label>Book title:</label>
<input type="text" name="title">
<br>
<label>Author:</label>
<input type="text" name="author">
<br>
<label>Pages:</label>
<input type="number" name="pages">
<br>
<label for="genre">Genre:</label>
<select id="genre" name="genre">
<option value="Technical">Technical</option>
<option value="Self-Help">Self-Help</option>
<option value="Fiction">Fiction</option>
<option value="Non-fiction">Non-Fiction</option>
<option value="Biography">Biography</option>
</select>
<br>
<label for="chargePerDay">Charge per day:</label>
<input type="checkbox" id="chargePerDay" name="chargePerDay" onclick="toggleChargeAmount()">
<div id="chargeAmount" style="display: none;">
<label for="charge">Charge Amount:</label>
<input type="text" id="charge" name="charge">
</div>
<br>
<label for="freeOfCost">Free of Cost:</label>
<input type="checkbox" id="freeOfCost" name="freeOfCost">
<br>
<label for="image">Image link:</label>
<input type="text" name="image" id="image">
<br>
<label for="synopsis">Synopsis:</label>
<textarea id="synopsis" name="synopsis" rows="4" cols="50"></textarea>
<br>
<label for="Personal info">Personal info:</label>
<br>
<label for="Name">Name:</label>
<input type="text" name="Name">
<br>
<label for="birthday">Date of Birth:</label>
<input type="date" id="birthday" name="birthday">
<br>
<label>Gender:</label>
<select id="gender" name="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
<option value="Prefer-not-say">Prefer not to say</option>
</select>
<br>
<label for="email">Email:</label>
<input type="email" name="email">
<br>
<label for="phone">Phone number:</label>
<input type="tel" name="phone">
<br>
<label for="pincode">Pincode:</label>
<input type="text" name="pincode">
<br>
<button class="but" id="submit-button">Submit</button>
</div>
<script>
function toggleChargeAmount() {
var perdaychargeCheckbox = document.getElementById("chargePerDay");
var freeofcostCheckbox = document.getElementById("freeofcost");
var chargeAmountDiv = document.getElementById("chargeAmount");
if (perdaychargeCheckbox.checked) {
chargeAmountDiv.style.display = "block";
freeofcostCheckbox.checked = false;
} else if (freeofcostCheckbox.checked) {
chargeAmountDiv.style.display = "none";
perdaychargeCheckbox.checked = false;
} else {
chargeAmountDiv.style.display = "none";
}
}
document.getElementById("submit-button").addEventListener("click", async () => {
const chargePerDayCheckbox = document.querySelector('input[name="chargePerDay"]');
let chargeValue = 0;
let freeOfCost = 0;
if (chargePerDayCheckbox.checked) {
chargeValue = parseFloat(document.querySelector('input[name="charge"]').value);
freeOfCost = 0;
} else {
chargeValue = 0;
freeOfCost = document.querySelector('input[name="freeOfCost"]').checked ? 1 : 0;
}
const bookData = {
bookDetails: {
title: document.querySelector('input[name="title"]').value,
author: document.querySelector('input[name="author"]').value,
pages: parseInt(document.querySelector('input[name="pages"]').value),
genre: document.querySelector('select[name="genre"]').value,
chargePerDay: chargeValue,
freeOfCost: freeOfCost,
image: document.querySelector('input[name="image"]').value,
synopsis: document.querySelector('textarea[name="synopsis"]').value,
},
personalInfo: {
Name: document.querySelector('input[name="Name"]').value,
birthday: document.querySelector('input[name="birthday"]').value,
gender: document.querySelector('select[name="gender"]').value,
email: document.querySelector('input[name="email"]').value,
phone: document.querySelector('input[name="phone"]').value,
pincode: document.querySelector('input[name="pincode"]').value,
}
};
// Send a POST request to the server
try {
const response = await fetch("https://nodejs--srinipositivevi.repl.co/book", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(bookData)
});
if (response.ok) {
const responseData = await response.json();
alert(responseData.message);
window.location.href='booksoption.html'
} else {
alert("Failed to register the book.");
}
} catch (error) {
console.error("Error:", error);
alert("Internal server error");
}
});
</script>
</body>
</html>