Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- };
- // Initialize Firebase
- firebase.initializeApp(firebaseConfig);
- // Function that grabs data from the form and sends it to Firebase along with the current date and time
- function FormSubmission(){
- // Generate the current time and date...
- var today = new Date();
- var date = today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds() + '-' + today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
- // Create a connection variable to the database called 'myDBConn'
- var myDBConn = firebase.database().ref();
- // Link to a 'child' branch in the database, in this case 'MyTemperatures'
- var TempBranch = myDBConn.child("MyTemperatures");
- // Get the Temperature from the HTML form and save it into variable currentTemp
- var currentTemp = document.getElementById("UserData");
- // Push both the currentTemp (as an int) and the date into the child branch 'Temperatures'
- TempBranch.push({Temperature: parseInt(currentTemp.value), Time: date});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement