-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (40 loc) · 1.29 KB
/
app.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
//Unique Firebase Object
var firebaseConfig = {
apiKey: "AIzaSyAxYmVWCC052ZGGco0--6ZWufV8iPYW_yQ",
authDomain: "blockchainemba-cf0ba.firebaseapp.com",
projectId: "blockchainemba-cf0ba",
storageBucket: "blockchainemba-cf0ba.appspot.com",
messagingSenderId: "317488766246",
appId: "1:317488766246:web:f3fb134ee6ebdc398c35e7",
measurementId: "G-KYCZ66C8M2"
};
//Initialize Firebase
firebase.initializeApp(firebaseConfig);
var firestore = firebase.firestore()
//Variable to access database collection
const db = firestore.collection("fomData")
//Get Submit Form
let submitButton = document.getElementById('submit')
//Create Event Listener To Allow Form Submission
submitButton.addEventListener("click", (e) => {
//Prevent Default Form Submission Behavior
e.preventDefault()
//Get Form Values
let firstName = document.getElementById('fname').value
let lastName = document.getElementById('lname').value
let mail = document.getElementById('mail').value
let refer = document.getElementById('refer').value
//Save Form Data To Firebase
db.doc().set({
fname: firstName,
lname: lastName,
mail: mail,
refer: refer
}).then( () => {
console.log("Data saved")
}).catch((error) => {
console.log(error)
})
//alert
alert("Your Form Has Been Submitted Successfully")
})