1521739101
This commit is contained in:
parent
fdf26c19f0
commit
5470b8cf71
41
.goutputstream-KEI9FZ
Normal file
41
.goutputstream-KEI9FZ
Normal file
@ -0,0 +1,41 @@
|
||||
"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++;
|
||||
}
|
||||
|
||||
function addBook(event){
|
||||
event.preventDefault();
|
||||
console.log("Add Book", event.target.bookTitle.value);
|
||||
let bookId = genBookId();
|
||||
let row = `
|
||||
<tr id="bookRow${bookId}">
|
||||
<td>${bookId + 1}</td>
|
||||
<td>${event.target.bookTitle.value}</td>
|
||||
<td>${event.target.bookGenre.value}</td>
|
||||
<td>${event.target.bookDesc.value}</td>
|
||||
<td>
|
||||
<button>Edit</button>
|
||||
<button onclick="deleteBook(${bookId})">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
`
|
||||
|
||||
bookTable.innerHTML = bookTable.innerHTML + row;
|
||||
}
|
||||
|
||||
function deleteBook() {
|
||||
console.log("Delete Book");
|
||||
}
|
||||
|
||||
function editBook() {
|
||||
console.log("Edit book");
|
||||
}
|
Loading…
Reference in New Issue
Block a user