-
Notifications
You must be signed in to change notification settings - Fork 0
/
proba.html
63 lines (55 loc) · 2.42 KB
/
proba.html
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
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-database.js"></script>
</head>
<body>
<form>
<label for="parent-name">Parent Name:</label>
<input type="text" id="parent-name" name="parent-name"><br><br>
<label for="child-name">Child Name:</label>
<input type="text" id="child-name" name="child-name"><br><br>
<label for="child-value">Child Value:</label>
<input type="text" id="child-value" name="child-value"><br><br>
<button type="submit" id="submit-button">Submit</button>
</form>
<script>
// firebase configuration and setup
var firebaseConfig = {
apiKey: "AIzaSyBB00grLIfvhq7EEQV6qiZUZuayP4-GoAg",
authDomain: "blog-25253.firebaseapp.com",
databaseURL: "https://blog-25253-default-rtdb.europe-west1.firebasedatabase.app",
projectId: "blog-25253",
storageBucket: "blog-25253.appspot.com",
messagingSenderId: "906101390805",
appId: "1:906101390805:web:871c51f2486921f443115c",
measurementId: "G-MY3P2TWN4L"
};
firebase.initializeApp(firebaseConfig);
var database = firebase.database();
// reference to the input fields and submit button
var parentNameInput = document.getElementById("parent-name");
var childNameInput = document.getElementById("child-name");
var childValueInput = document.getElementById("child-value");
var submitButton = document.getElementById("submit-button");
// add event listener to the submit button to save the data to the database
submitButton.addEventListener("click", function(event) {
event.preventDefault(); // prevent form from submitting
// get the values from the input fields
var parentName = parentNameInput.value;
var childName = childNameInput.value;
var childValue = childValueInput.value;
// reference to the location where you want to store the data
var parentRef = database.ref().child(parentName);
var childRef = parentRef.child(childName);
// set the data at the location referenced in the previous step
childRef.set(childValue);
// clear the input fields
parentNameInput.value = "";
childNameInput.value = "";
childValueInput.value = "";
});
</script>
</body>
</html>