2
I have a form with the following fields (I will put only one, as an example):
<div class="form-group">
<label for="nomeAutor"><i class="zmdi zmdi-account material-icons-name"></i></label>
<input type="text" name="nomeAutor" id="nomeAutor" placeholder="Nome do autor" />
</div>
I’ve also named the querySelector()
to record the field value:
var nomeDoAutor = document.querySelector("#nomeAutor").value;
And finally, I wrote the code to do the research and render the results list:
document.getElementById("submit").addEventListener("click", event => {
db.collection("textos").where('nomeDoAutor', '==', 'nomeAutorTexto').get().then((snapshot) => {
snapshot.docs.forEach(doc => {
console.log(doc.data())
renderLista(doc)
});
});
});
But ... it didn’t work :-(
What am I missing?
Grateful!
Are you comparing the literal string 'authorName' to 'authorName'? It was not meant to be comparing to variable
nomeDoAutor
with 'AutorText'? Also remember to take the value of the '#authorname' element after clicking, not before.– Andre
"Didn’t work" can be many things. What didn’t work? What was the result? Shows console error or shows blank?
– Sam
@user140828, well punctuated, I think I get it, I’ll try :-)
– LuizC
@Sam, the console is empty. I’ll test my colleague’s suggestion above and I’ll be right back!
– LuizC
@user140828, I left the capture of value for the
var nomeDoAutor
after the click, but it hasn’t worked yet and as I told @Sam, the console is empty. I also THOUGHT I understood your position on comparison of the variables but I really didn’t understand, because I still THINK it is correct. You could deepen your suggestion, always remembering my noobice ?– LuizC
@Sam,
'nomeAutorTexto'
is the comic book field with which I need to research the value of the fieldnomeDoAutor
. I followed your suggestion and the console gave an error message: Error: Function Query.Where() called with invalid data. Invalid field path(). Paths must not be Empty, Begin with '.', end with '.', or contain '..' Any suggestions?– LuizC
One strange thing: despite the command on the console
firebase init
andfirebase deploy
, in the Functions section of the Firebase console has no function listed. :-(– LuizC