0

This my code

btn.addEventListener("click", writeData);
 function writeData() {
  database.ref("todo" + item).set({
  item: document.getElementById("input").value
 });
}

There is no problem when I manually send string values but when I try to send the input value it returns empty. What should I do ? I'm new to firebase

enter image description here

  • Remove the parenthesis after `writeData` when you pass it to `addEventListener` (so `btn.addEventListener("click", writeData);`). You want to pass it as a reference, instead of executing it immediately and passing the return value. – Ivar Jan 16 '21 at 16:15
  • I tried but it didn't work. –  Jan 16 '21 at 16:24
  • 1
    Show the updated code in your question please. – Frank van Puffelen Jan 16 '21 at 16:32

0 Answers0