forked from Anushkabh/krishiconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homescript.js
47 lines (34 loc) · 1.46 KB
/
homescript.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
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.10/firebase-app.js";
import { getFirestore, setDoc, addDoc,doc, updateDoc,deleteDoc, getDoc, query, collection, where, getDocs, onSnapshot } from "https://www.gstatic.com/firebasejs/9.6.10/firebase-firestore.js";
const firebaseConfig = {
apiKey: "AIzaSyAmVZazd1cBsO5mftadw5HppCKu-JC4GRY",
authDomain: "krishiconnect-64752.firebaseapp.com",
databaseURL: "https://krishiconnect-64752-default-rtdb.asia-southeast1.firebasedatabase.app",
projectId: "krishiconnect-64752",
storageBucket: "krishiconnect-64752.appspot.com",
messagingSenderId: "641022690248",
appId: "1:641022690248:web:0f6761e2847339d69536fd",
measurementId: "G-4Z04QQF90G"
};
firebase.initializeApp(firebaseConfig);
var productFormDB = firebase.database().ref("contactForm");
window.listproduct=(e)=>{
var product = getElementVal("product");
var category = getElementVal("category");
var quantity = getElementVal("quantity");
var unit = getElementVal("unit");
saveProduct(name, emailid, msgContent);
// reset the form
document.getElementById("productform").reset();
}
const saveProduct = (name, emailid, msgContent) => {
var newContactForm = contactFormDB.push();
newProductForm.set({
name: name,
emailid: emailid,
msgContent: msgContent,
});
};
const getElementVal = (id) => {
return document.getElementById(id).value;
};