-
Notifications
You must be signed in to change notification settings - Fork 21
/
Library Management System
82 lines (78 loc) · 2.12 KB
/
Library Management System
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Library </title>
</head>
<body bgcolor="gray">
<h1><center><i>Library Management System</i></h1></center>
<label for="bookTitle">Book Title:<br></label>
<input type="text" id="bookTitle"><br>
<label for="authorName">Author:</label><br>
<input type="text" id="authorName"><br>
<label for="yearOfPublication">Year of Publication:</label><br>
<input type="number" id="yearOfPublication"><br>
<button onclick="addBook()">Add Book</button><br>
<ul id="bookList">
<br>
<bd>
<h2>My Library Store:</h2>
</bd>
</ul><br>
<!-- Book items will be added here -->
</ul>
<script src="script.js"></script>
</body>
</html>
<script>
function addBook() {
const bookTitle = document.getElementById("bookTitle").value;
const authorName = document.getElementById("authorName").value;
const yearOfPublication = parseInt(document.getElementById("yearOfPublication").value);
const currentYear = new Date().getFullYear();
const ageOfBook = currentYear - yearOfPublication;
const bookList = document.getElementById("bookList");
const bookItem = document.createElement("li");
bookItem.innerHTML = `${bookTitle} Written by ${authorName} (Published in
${yearOfPublication}, ${ageOfBook} years old) <button
onclick="removeBook(this)">Remove</button>`;
bookList.appendChild(bookItem);
document.getElementById("bookTitle").value = "";
document.getElementById("authorName").value = "";
document.getElementById("yearOfPublication").value = "";
}
function removeBook(button) {
const bookItem = button.parentNode;
bookItem.parentNode.removeChild(bookItem); }
alert("Welcome To KCE Library!");
</script>
<style>
label {
color: black;
font-style:inherit ;
}
button {
font-size: 150%;
font-size:medium;
color: darkgreen;
}
input {
font-size: 150%;
color:red;
border-color: darkred;
}
h2{
color: darkred;
}
</style>
</body>
</html>