<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="Bootstrap.css">
<title>Book List</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
</head>
<body>
<div class="container mt-4">
<h1 class="display-4 text-center">
My <span class="text-primary">Book</span>List
</h1>
<form id="book-form">
<div class="form-group">
<label for="title">Title</label>
<input type="text" id="title" class="form-control" />
</div>
<div class="form-group">
<label for="author">Author</label>
<input type="text" id="author" class="form-control" />
</div>
<div class="form-group">
<label for="isbn">ISBN</label>
<input type="text" id="isbn" class="form-control" />
</div>
<input type="submit" value="Add Book" class="btn btn-primary btn-block">
</form>
<table class="table table-striped mt-5">
<thead>
<tr>
<th>Title</th>
<th>Author</th>
<th>ISBN</th>
</tr>
</thead>
<tbody id="book-list"></tbody>
</table>
</div>
<script src="index.js"></script>
</body>
</html>
<script>
const titleInput = document.querySelector("#title");
const authorInput = document.querySelector("#author");
const isbnInput = document.querySelector("#isbn");
const button = document.querySelector("input[type='submit']");
const bookList = document.querySelector("#book-list");
button.addEventListener("click", function (event) {
event.preventDefault();
if (titleInput.value === "" || authorInput.value === "" || isbnInput.value === "") {
alert("Please enter all inputs");
} else {
const bookListRow = document.createElement("tr");
const newTitle = document.createElement("td");
newTitle.textContent = titleInput.value;
bookListRow.appendChild(newTitle);
const newAuthor = document.createElement("td");
newAuthor.textContent = authorInput.value;
bookListRow.appendChild(newAuthor);
const newISBN = document.createElement("td");
newISBN.textContent = isbnInput.value;
bookListRow.appendChild(newISBN);
bookList.appendChild(bookListRow);
titleInput.value = "";
authorInput.value = "";
isbnInput.value = "";
}
});
</script>