lundi 24 septembre 2018

Firebase Web Structure

[Open the Picture to see what I have now1

This is what I want!!! https://i.stack.imgur.com/erVT6.png

Hi I need some help.

If you look at the image, you´ll see the structure of my firebase database.

I want that there is a real Id or a random Id something like this if you make a normal database as you can see in the other image: "uOJFrspo8fm" "doisu4irp4cr0"

My code is below what do I have to change.

Thank you for your help!

<html>
  <head>
    <meta charset="utf-8"/>
    <script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script>
    <title>Firebase example</title>
  </head>
  <body>
    <h1>Firebase example</h1>

      <form id="myform" method="post">
    <input type="email" id="userCityEmail" placeholder="Enter email">
    <input type="text" id="cityTextField" placeholder="City">
    <button id="citySubmitButton" onclick="submitCityClick(); return false;">Submit</button>
</form>

   <script>
  // Initialize Firebase
  var config = {
    apiKey: "AIzaSyC7aXtPN_zzNth3cByFYvOMX7557xmvUP4",
    authDomain: "xchange-2c1a8.firebaseapp.com",
    databaseURL: "https://xchange-2c1a8.firebaseio.com",
    projectId: "xchange-2c1a8",
    storageBucket: "xchange-2c1a8.appspot.com",
    messagingSenderId: "47882954853"
  };
  firebase.initializeApp(config);

       var userCityEmail = document.getElementById('userCityEmail');
var cityTextField = document.getElementById('cityTextField');
var citySubmitButton = document.getElementById('citySubmitButton');

function submitCityClick() {
  var firebaseRef = firebase.database().ref();
  var userEmail = userCityEmail.value;
  var userCity = cityTextField.value;

    firebase.database().ref("Id").set({

        usermail:userEmail,
        usercity: userCity

    });

}

</script>

  </body>
</html>




Aucun commentaire:

Enregistrer un commentaire