-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg.js
52 lines (38 loc) · 1.37 KB
/
reg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const firebaseConfig = {
apiKey: "AIzaSyCGxLPUNbQEkB1GEjttahmioYSoIyMhw3E",
authDomain: "sparkhack-279c1.firebaseapp.com",
databaseURL: "https://sparkhack-279c1-default-rtdb.firebaseio.com",
projectId: "sparkhack-279c1",
storageBucket: "sparkhack-279c1.appspot.com",
messagingSenderId: "702636300696",
appId: "1:702636300696:web:50d005c06845b11e6933ed"
};
firebase.initializeApp(firebaseConfig);
var contactFormDB = firebase.database().ref('contactForm');
document.getElementById('contactForm').addEventListener('submit', submitForm);
function submitForm(e) {
e.preventDefault();
var name = getElementVal("name");
var email = getElementVal("email");
var subject = getElementVal("subject");
var message = getElementVal("message");
saveMessages(name, email, subject, message);
alert("Your Message was successfully sent to SparkHack Organizing Committee");
// document.querySelector(".alert").style.display = "block";
// setTimeout(() => {
// document.querySelector(".alert").style.display = "none";
// }, 3000);
document.getElementById("contactForm").reset();
}
const saveMessages = (name, email, subject, message) => {
var newContactForm = contactFormDB.push();
newContactForm.set({
name: name,
email: email,
subject: subject,
message: message,
});
};
const getElementVal = (id) => {
return document.getElementById(id).value;
};