Guest User

Untitled

a guest
Jun 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var showData = document.getElementById("showData");
  2. var button1 = document.getElementById("but1");
  3.  
  4. var usersRef =
  5. firebase.database().ref('stores/').orderByChild("sid").equalTo(123);
  6.  
  7.  
  8.  
  9. function s2_but() { //function gets trigger when button pressed
  10. usersRef.on('value', snap);
  11.  
  12. function snap(data) {
  13. data2 = data.val();
  14. console.log(data2);
  15. showData.innerHTML = data2.sname; //sname is the name of child key
  16. //whose value I want to show
  17. }
  18. };
  19.  
  20. entry1: {prod1: "coffee", prod2: "sandwich", sid: 123,
  21. sname: "Java Coffee"}
  22. __proto__:Object
  23.  
  24. <p id="showData"></p>
  25.  
  26. showData.innerHTML = data2.sname;
Add Comment
Please, Sign In to add comment