BACK

1
Posted by michael_andreuzza 4 months ago
So, it took me 2 days to figure it out how to do it, now is working and ready to collect Subscribers....

//<p class="has-text-white is-size-7-mobile is-size-7-tablet alert alert-success success-message " style="display:none;">SUBSCRIBED !.</p>
 //                                           <form class="field has-addons" id="contactForm">
 //                                               <div class="control  form-control ">
 //<input type="email" class="input is-small is-rounded form-control email" id="exampleEmail" placeholder="Enter Email" required>
 //                                               </div>
 //                                               <div class="control">
 //                                                   <button class="button is-small is-rounded is-primary" type="submit">
 //                                                       SUBSCRIBE
 //                                                   </button>
 //                                               </div>
 //                                          </form>
 
 
 
 var firebaseConfig = {
     apiKey: "xxx",
     authDomain: "xxx",
     databaseURL: "https://xxxxxxx-xxxx.firebaseio.com",
     projectId: "xxxxxxx-xxxx",
     storageBucket: "xxxxxxx-xxxx.appspot.com",
     messagingSenderId: "xxxxxxx",

 };


 firebase.initializeApp(firebaseConfig);


// Reference messages collection
var messagesRef = firebase.database().ref('contactformmessages');


//take all form values and pass it to the Firebase 

$('#contactForm').submit(function(e) {
    e.preventDefault();
 
    var newMessageRef = messagesRef.push();
    newMessageRef.set({
        
        email: $('.email').val(),
       
    });
 
    $('.success-message').show();
 
    $('#contactForm')[0].reset();
});