 const firebaseConfig = {
    apiKey: "AIzaSyDEj9RKTyw3ELjgbENi3DtwhyYZtSclm6I",
    authDomain: "Idea Assure.firebaseapp.com",
    databaseURL: "https://Idea Assure-default-rtdb.firebaseio.com",
    projectId: "Idea Assure",
    storageBucket: "Idea Assure.appspot.com",
    messagingSenderId: "1019311716171",
    appId: "1:1019311716171:web:e07db745c1a5717827dace",
    measurementId: "G-CSXHMCBXWX"
  };

  firebase.initializeApp(firebaseConfig);

  var contactFormDb = firebase.database().ref('Idea Assure');

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

  function submitForm(e){
      e.preventDefault();
      var Name = getElementVal('Name');
      var Email = getElementVal('Email');
      var ContactNo = getElementVal('ContactNo');
      var IdeaSolve = getElementVal('IdeaSolve');
      var Solution = getElementVal('Solution');
      var Gender = getElementVal('Gender');
      var Age = getElementVal('Age');
      var DeliverResults = getElementVal('DeliverResults');

      savedmessages(Name,Email,ContactNo,IdeaSolve,Solution,Gender,Age,DeliverResults);

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

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

  const savedmessages = (Name,Email,ContactNo,IdeaSolve,Solution,Gender,Age,DeliverResults) => {
      var newcontactform = contactFormDb.push();
      newcontactform.set({
          Name : Name,
          Email : Email,
          ContactNo : ContactNo,
        
          IdeaSolve:IdeaSolve,
          Solution:Solution,
          Gender:Gender,
          Age:Age,
          DeliverResults : DeliverResults,
      });
  };

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