"use strict";
console.log("App");
let addForm = document.getElementById("addFormElement");
addForm.addEventListener("submit", addBook);
let bookTable = document.getElementById("bookTableBody");
let lastBookId = 0;
function genBookId() {
return lastBookId++;
}
let books = {}
function addBook(event){
event.preventDefault();
console.log("Add Book", event.target.bookTitle.value);
let bookId = genBookId();
let row = `
${bookId + 1} |
${event.target.bookTitle.value} |
${event.target.bookGenre.value} |
${event.target.bookDesc.value} |
|
`
bookTable.innerHTML = bookTable.innerHTML + row;
}
function deleteBook(bookId) {
console.log("Delete Book", bookId);
let rowElement = document.getElementById("bookRow"+bookId);
bookTable.removeChild(rowElement);
}
function editBook(bookId) {
console.log("Edit book");
let rowElement = document.getElementById("bookRow"+bookId);
}