Initiate function to submit form and clear input fields
This commit is contained in:
parent
a67a870c42
commit
7a9d062e60
|
@ -1,5 +1,3 @@
|
||||||
console.log("Guestbook script successfully loaded");
|
|
||||||
|
|
||||||
// Import Firebase
|
// Import Firebase
|
||||||
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.12.0/firebase-app.js'
|
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'
|
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: '',
|
message: '',
|
||||||
timestamp: '',
|
timestamp: '',
|
||||||
replies: [],
|
replies: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
formEl.addEventListener('submit', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
clearInputEl();
|
||||||
|
console.log('Form submitted');
|
||||||
|
});
|
||||||
|
|
||||||
|
const clearInputEl = () => {
|
||||||
|
nameInputEl.value = '';
|
||||||
|
emailInputEl.value = '';
|
||||||
|
websiteInputEl.value = '';
|
||||||
|
msgInputEl.value = '';
|
||||||
};
|
};
|
|
@ -4,7 +4,7 @@
|
||||||
<subtitle>Leilukin's personal website.</subtitle>
|
<subtitle>Leilukin's personal website.</subtitle>
|
||||||
<link href="https://leilukin.neocities.org/feed.xml" rel="self"/>
|
<link href="https://leilukin.neocities.org/feed.xml" rel="self"/>
|
||||||
<link href="https://leilukin.neocities.org"/>
|
<link href="https://leilukin.neocities.org"/>
|
||||||
<updated>2024-05-19T06:23:25Z</updated>
|
<updated>2024-05-19T06:29:00Z</updated>
|
||||||
<id>https://leilukin.neocities.org</id>
|
<id>https://leilukin.neocities.org</id>
|
||||||
<author>
|
<author>
|
||||||
<name>Leilukin</name>
|
<name>Leilukin</name>
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
console.log("Guestbook script successfully loaded");
|
|
||||||
|
|
||||||
// Import Firebase
|
// Import Firebase
|
||||||
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.12.0/firebase-app.js'
|
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'
|
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: '',
|
message: '',
|
||||||
timestamp: '',
|
timestamp: '',
|
||||||
replies: [],
|
replies: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
formEl.addEventListener('submit', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
clearInputEl();
|
||||||
|
console.log('Form submitted');
|
||||||
|
});
|
||||||
|
|
||||||
|
const clearInputEl = () => {
|
||||||
|
nameInputEl.value = '';
|
||||||
|
emailInputEl.value = '';
|
||||||
|
websiteInputEl.value = '';
|
||||||
|
msgInputEl.value = '';
|
||||||
};
|
};
|
Loading…
Reference in New Issue