Açıklama Yok

AddDelProductsFirebase Js.html 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <html>
  2. <head><title> Read, write, Update, Deleta Data Firebase JS</title></head>
  3. <body>
  4. productId <input id="idbox" type="text"></input><br><br>
  5. attribute <input id="attributebox" type="text"></input><br><br>
  6. category <input id="categorybox" type="text"></input><br><br>
  7. imageUrl <input id="imageUrlbox" type="text"></input><br><br>
  8. marketPrice <input id="marketPricebox" type="text"></input><br><br>
  9. name <input id="namebox" type="text"></input><br><br>
  10. ourPrice <input id="ourPricebox" type="text"></input><br><br>
  11. units <input id="unitsbox" type="text"></input><br><br>
  12. <br><br>
  13. <button id = "insert">INSERT</button>
  14. <button id = "select">SELECT</button>
  15. <button id = "update">UPDATE</button>
  16. <button id = "delete">DELETE</button>
  17. <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
  18. <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-auth.js"></script>
  19. <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-database.js"></script>
  20. <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script>
  21. <script id="MainScript">
  22. var firebaseConfig = {
  23. apiKey: "AIzaSyAilkN9V1yNMfqCvPGTeiovVLOBSx1w1cc",
  24. authDomain: "comedoresescolares-82ede.firebaseapp.com",
  25. databaseURL: "https://comedoresescolares-82ede-default-rtdb.firebaseio.com",
  26. projectId: "comedoresescolares-82ede",
  27. storageBucket: "comedoresescolares-82ede.appspot.com",
  28. messagingSenderId: "182848144209",
  29. appId: "1:182848144209:web:27dfc87c0c49d2f9534970",
  30. measurementId: "G-4KK5ME3PJ5"
  31. };
  32. // Initialize Firebase
  33. firebase.initializeApp(firebaseConfig);
  34. firebase.analytics();
  35. //var productV
  36. var attributeV, categoryV, imageUrlV, marketPriceV, nameV, ourPriceV, unitsV;
  37. function Ready(){
  38. productV = document.getElementById('idbox').value;
  39. attributeV = document.getElementById('attributebox').value;
  40. categoryV = document.getElementById('categorybox').value;
  41. imageUrlV = document.getElementById('imageUrlbox').value;
  42. marketPriceV = document.getElementById('marketPricebox').value;
  43. nameV = document.getElementById('namebox').value;
  44. ourPriceV = document.getElementById('ourPricebox').value;
  45. unitsV = document.getElementById('unitsbox').value;
  46. }
  47. document.getElementById('insert').onclick = function(){
  48. Ready();
  49. firebase.database().ref('products/'+ Math.random().toString(36).substring(2,9)).set ({
  50. //productId: productV,
  51. attribute: attributeV,
  52. categoryId: categoryV,
  53. imageUrl: imageUrlV,
  54. marketPrice: marketPriceV,
  55. name: nameV,
  56. ourPrice: ourPriceV,
  57. units: unitsV
  58. })
  59. }
  60. document.getElementById('delete').onclick = function(){
  61. Ready();
  62. firebase.database().ref('Product/'+ productV).remove();
  63. }
  64. </script>
  65. </body>
  66. </html>