title: How to insert items in firebase database using different IDs?
body: <p>I have a simple database on firebase and basically I'm trying to create a code to insert records on this database. I wanted to insert records like this:</p>
  
  <pre><code>id | lat | lng
  01 | -55 | -10
  02 | -44 | -20
  </code></pre>
  
  <p>each "row" is a new record of a place (latitude and longitude).</p>
  
  <p>I created this example on firebase:</p>
  
  <p><a href="https://i.stack.imgur.com/RBYh6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RBYh6.png" alt="enter image description here"></a></p>
  
  <p>How can I insert records into this "table" properly??? Because when I created the following code to implement it and I hit the button, it creates a different ID on this table (I'm new to Firebase, I don't get this yet):</p>
  
  <p><a href="https://i.stack.imgur.com/vLUZg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vLUZg.png" alt="enter image description here"></a></p>
  
  <p>Here is the full code:</p>
  
  <p>
    </p>
  
  <p>
    </p>
  
  <pre><code>&lt;form action="" id="newActivity"&gt;
  &lt;input id="searchTextField" type="text" size="50" placeholder="Enter a location" autocomplete="on" runat="server" /&gt;  
  &lt;input type="hidden" id="city2" name="city2" /&gt;
  &lt;input type="hidden" id="cityLat" name="cityLat" /&gt;
  &lt;input type="hidden" id="cityLng" name="cityLng" /&gt; 
  &lt;input id="saveForm" name="saveForm" type="submit" value="New Activity"&gt;
  &lt;/form&gt;
  
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"&gt;&lt;/script&gt;
  &lt;script src="http://maps.googleapis.com/maps/api/js?libraries=places" type="text/javascript"&gt;&lt;/script&gt;
  
  
  &lt;script type="text/javascript"&gt;
      function initialize() {
          var input = document.getElementById('searchTextField');
          var autocomplete = new google.maps.places.Autocomplete(input);
          google.maps.event.addListener(autocomplete, 'place_changed', function () {
              var place = autocomplete.getPlace();
              document.getElementById('city2').value = place.name;
              document.getElementById('cityLat').value = place.geometry.location.lat();
              document.getElementById('cityLng').value = place.geometry.location.lng();
              //alert("This function is working!");
              //alert(place.name);
             // alert(place.address_components[0].long_name);
  
          });
      }
      google.maps.event.addDomListener(window, 'load', initialize); 
  &lt;/script&gt;
  
  
  &lt;script&gt;
  
  
  
      $(function(){
  
          var rootRef = new Firebase("https://xxxx.firebaseio.com/").ref();
          var placesRef = rootRef.child('places');
  
  
          /**
          * Data object to be written to Firebase.
          */
          var data = []
  
  
        $('#newActivity').submit(function(event){
  
            var $form = $(this);
            console.log("submit to Firebase");
  
            //make the submit disabled
            //$form.find("#saveForm").prop('disabled', true);
  
            //get the actual values that we will send to firebase
            var cityLatToSend = $('#cityLat').val();
  
            console.log(cityLatToSend);
  
            var cityLngToSend = $('#cityLng').val();
  
            console.log(cityLngToSend);
  
            //take the values from the form, and put them in an object
  
  
            var newActivity = {
              "lat": cityLatToSend,
              "lng": cityLngToSend,
            }
  
  
            //put the new object into the data array
            data.push(newActivity);
            console.log(data);
            //send the new data to Firebase
  
            var newPlaceRef = rootRef.push();
            newPlaceRef.set(data);
            //rootRef.push(data);
  
  
  
            return false;
  
        })
    })
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>