I'm trying to save a "task" in the live database and I want it to be saved in an account name reference. And it goes beyond the username.
Function to save tasks:
function savetask() { var task = input.value; //* ENVIA O VALOR DO INPUT (task) ASSOCIADO AO NOME RECOLHIDO A CIMA PARA A DATABASE DA FIREBASE firebase.database().ref('nomes').push( task ); console.log('A seguinte tarefa foi enviada para a database:', task) } inputnota.addEventListener('submit', savetask)
Function to save name to database:
function savename(nome) { var nome = document.getElementById("nome").value; //* save in database firebase.database().ref('nomes').child(nome).push({ 'nome:':nome }); console.log('teu nome:',nome) alert('Welcome:',nome) //* prevent form from submitting return false }
You are missing
nome
in this snippet:So to make it write to the same path you need:
Or read
nome
from HTML, just like you do in other code blocks: