title: Save items to different childs in firebase
body: <p>How can I save data to different childs in a firebase?</p>
  
  <p>I push items to a firebase using onclick function and if/else statements for creating different categories.
  <br>
  <br><strong>Example</strong>
  <br>
  Button1 click -> push data from inputform to child1 in firebase,
  <br>
  Button2 click -> push data from inputform to child2 in firebase....</p>
  
  <p><strong>Problem</strong>
  <br>
  The item is pushed to one child only (e.g. ref0).
  Everytime I push further items into the firebase, there appended to the ref0 child and not assigned to a new child (e.g. ref1).</p>
  
  <p>Unfortunately I can´t find specific information for solving this issue.
  Would be great if you can support me.
  Check my Code for more specific information.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//create firebase reference
  var dbRef = new Firebase('https://firebaseurl.firebaseio.com/');
  var ref0 = dbRef.child('ref0');
  var ref1 = dbRef.child('ref1');
  var ref2 = dbRef.child('ref2');
  var ref3 = dbRef.child('ref3');
  
  var showAllRefs = ref0, ref1, ref2, ref3;
  
  //load all contacts (limited to last 5 items)
  showAllRefs.limitToLast(5).on("child_added", function(snap) {
    snap.forEach(function(childSnapshot) {
    var key = childSnapshot.key();
    var childData = childSnapshot.val();
  
    //create divs from database-elements
    var card = document.createElement('div');
    card.setAttribute('class', 'linkprev');
    $('#content').prepend($(card));
    
    var cardtitle = document.createElement('div');
    cardtitle.setAttribute('class', 'cardtitle');
    cardtitle.innerHTML = childData;
    card.appendChild(cardtitle);
    });
    $(document).ready(function(){
    document.guteUrls.execute('linkprev');
  });
  });
  
  //save contact
    //save in database contacts
    var elements = $('.f');
    //console.log(elements);
  
  
  //save items to firebase(childs)
    var buttonPressed = function( event ) {  
      event.preventDefault();
        
      //url validation from inputfield using Regex
      var valpattern = new RegExp('^(http|https)://'+ // protocol
      '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+ // domain name
      '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
      '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
      '(\\?[;&amp;a-z\\d%_.~+=-]*)?'+ // query string
      '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
      var valselect = document.getElementById('url');
      var val = valpattern.test(valselect.value);
      
      //save in database to different childs on buttonclick
      if(val &amp;&amp; document.querySelector(".f1")){ref0.push({name: document.querySelector('#url').value})
        contactForm.reset();}
      else if(val &amp;&amp; document.querySelector(".g1")){ref1.push({name: document.querySelector('#url').value})
        contactForm.reset();}
      else if(val &amp;&amp; document.querySelector(".h1")){ref2.push({name: document.querySelector('#url').value})
        contactForm.reset();}
      else if(val &amp;&amp; document.querySelector(".i1")){ref3.push({name: document.querySelector('#url').value})
        contactForm.reset();}
      else {
      alert('Oops');}
  };
  
  for (var i = 0; i &lt; elements.length; i++) {elements[i].addEventListener("click", buttonPressed, false);}</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks in advance
  <br>
  Ben</p>