2024-01-14 01:09:31 +01:00
|
|
|
let commentForm = document.getElementById("commentForm");
|
|
|
|
|
|
|
|
|
|
|
|
commentForm.addEventListener("submit", (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
let name = document.getElementById("name")
|
|
|
|
let comment = document.getElementById("comment")
|
|
|
|
|
|
|
|
console.log(name.value)
|
|
|
|
console.log(comment.value)
|
|
|
|
|
|
|
|
let post = name.name // The post number ie 0 is stored in the name tag of the input field
|
|
|
|
|
|
|
|
comments[post].push(`${name.value}: ${comment.value}`)
|
|
|
|
console.log(comments)
|
2024-01-20 23:58:14 +01:00
|
|
|
|
|
|
|
$.post('/comment', { comment: comment.value })
|
|
|
|
$.post('/name', { name: name.value })
|
2024-01-14 01:09:31 +01:00
|
|
|
});
|