mercredi 1 août 2018

Javascript not working for the first time when webpage open?

I am working on a project where I need to send my data to the firebase of the form.

Link - https://ietvit.com/hackoff

But on filling out the form it should pop up alert window and submit the form but when I open the website for the first time it does not do anything when it refreshes instead it starts to work perfectly but not for the first time. Any reason why or any suggestions to prevent.

Example :

I open my website for the first time and fills out the subscribe form but it just simply refreshes the page instead of updating firebase and pop-ing alert window.

My html form -

And don’t worry, we hate spam too! You can unsubcribe at anytime.
Submit

My java script -

var nameText = document.getElementById("name");
var emailText = document.getElementById("email");
var submitBtn = document.getElementById("submitBtn");

const firebaseRef = firebase.database().ref();




function submitDetail(){

    var nText = nameText.value;
    var eText = emailText.value;

    firebaseRef.push().set({
        name : nText,
        email : eText
    });

    window.alert("Subscribed Successfully")

}




Aucun commentaire:

Enregistrer un commentaire