 const firebaseConfig = {
    apiKey: "AIzaSyBymltyw8G9ydeUNlxm3wRFOVASFfR6asQ",
    authDomain: "feedbacksform.firebaseapp.com",
    databaseURL: "https://feedbacksform-default-rtdb.firebaseio.com",
    projectId: "feedbacksform",
    storageBucket: "feedbacksform.appspot.com",
    messagingSenderId: "323146512026",
    appId: "1:323146512026:web:e9162b20d7f4149e3e5123",
    measurementId: "G-ZVCT1NV1SF"
  };

  firebase.initializeApp(firebaseConfig);

  var contactFormDb = firebase.database().ref('FeedBackForm');

  document.getElementById('frmFeedback').addEventListener('submit',submitForm);

  function submitForm(e){
      e.preventDefault();
      var Name = getElementVal('Name');
      var Email = getElementVal('Email');
      var ContactNo = getElementVal('ContactNo');
      var AreaofFeedback = getElementVal('AreaofFeedback');
      var Message = getElementVal('Message');

      savedmessages(Name,Email,ContactNo,AreaofFeedback,Message);

      document.querySelector('.alert').style.display = 'block';

      setTimeout(() => {
      document.querySelector('.alert').style.display = 'none';
      },2000);
      document.getElementById('frmFeedback').reset();
  }

  const savedmessages = (Name,Email,ContactNo,AreaofFeedback,Message) => {
      var newcontactform = contactFormDb.push();
      newcontactform.set({
          Name : Name,
          Email : Email,
          ContactNo : ContactNo,
          Message : Message,
          AreaofFeedback : AreaofFeedback,
      });
  };

  const getElementVal = (id) => {
  return document.getElementById(id).value;
  };
