From 7a9d062e6038698fca8a1544c410aa239af37d10 Mon Sep 17 00:00:00 2001
From: Helen Chong <119173961+helenclx@users.noreply.github.com>
Date: Sun, 19 May 2024 14:30:19 +0800
Subject: [PATCH] Initiate function to submit form and clear input fields
---
_site/assets/js/guestbook.js | 15 +++++++++++++--
_site/feed.xml | 2 +-
src/assets/js/guestbook.js | 15 +++++++++++++--
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/_site/assets/js/guestbook.js b/_site/assets/js/guestbook.js
index 89d77484..a8617949 100644
--- a/_site/assets/js/guestbook.js
+++ b/_site/assets/js/guestbook.js
@@ -1,5 +1,3 @@
-console.log("Guestbook script successfully loaded");
-
// Import Firebase
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.12.0/firebase-app.js'
import { getDatabase, ref, push, onValue, update } from 'https://www.gstatic.com/firebasejs/10.12.0/firebase-database.js'
@@ -29,4 +27,17 @@ let messageObj = {
message: '',
timestamp: '',
replies: [],
+};
+
+formEl.addEventListener('submit', (e) => {
+ e.preventDefault();
+ clearInputEl();
+ console.log('Form submitted');
+});
+
+const clearInputEl = () => {
+ nameInputEl.value = '';
+ emailInputEl.value = '';
+ websiteInputEl.value = '';
+ msgInputEl.value = '';
};
\ No newline at end of file
diff --git a/_site/feed.xml b/_site/feed.xml
index 3d6258ed..9ebad38c 100644
--- a/_site/feed.xml
+++ b/_site/feed.xml
@@ -4,7 +4,7 @@
Leilukin's personal website.
- 2024-05-19T06:23:25Z
+ 2024-05-19T06:29:00Z
https://leilukin.neocities.org
Leilukin
diff --git a/src/assets/js/guestbook.js b/src/assets/js/guestbook.js
index 89d77484..a8617949 100644
--- a/src/assets/js/guestbook.js
+++ b/src/assets/js/guestbook.js
@@ -1,5 +1,3 @@
-console.log("Guestbook script successfully loaded");
-
// Import Firebase
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.12.0/firebase-app.js'
import { getDatabase, ref, push, onValue, update } from 'https://www.gstatic.com/firebasejs/10.12.0/firebase-database.js'
@@ -29,4 +27,17 @@ let messageObj = {
message: '',
timestamp: '',
replies: [],
+};
+
+formEl.addEventListener('submit', (e) => {
+ e.preventDefault();
+ clearInputEl();
+ console.log('Form submitted');
+});
+
+const clearInputEl = () => {
+ nameInputEl.value = '';
+ emailInputEl.value = '';
+ websiteInputEl.value = '';
+ msgInputEl.value = '';
};
\ No newline at end of file