Advertisement
Guest User

ssd12

a guest
Dec 13th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. };
  2. // Initialize Firebase
  3. firebase.initializeApp(firebaseConfig);
  4.  
  5.  
  6. // Function that grabs data from the form and sends it to Firebase along with the current date and time
  7. function FormSubmission(){
  8.  
  9. // Generate the current time and date...
  10. var today = new Date();
  11. var date = today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds() + '-' + today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
  12.  
  13. // Create a connection variable to the database called 'myDBConn'
  14. var myDBConn = firebase.database().ref();
  15.  
  16. // Link to a 'child' branch in the database, in this case 'MyTemperatures'
  17. var TempBranch = myDBConn.child("MyTemperatures");
  18.  
  19. // Get the Temperature from the HTML form and save it into variable currentTemp
  20. var currentTemp = document.getElementById("UserData");
  21.  
  22. // Push both the currentTemp (as an int) and the date into the child branch 'Temperatures'
  23. TempBranch.push({Temperature: parseInt(currentTemp.value), Time: date});
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement