Home > Mobile >  Set firebase child name from text input
Set firebase child name from text input

Time:09-07

This is input:

<input type="text"  id="name" maxlength="10" required placeholder="Enter Username">

And this is Javascript:

contactsRef.child("users/"   auth.uid   "/moath")
.set({ a1: $('#name').val(),})

This is what I get hello

In JavaScript i have /moath I don't want it.

But I want to set child name from input

I have tried this:

contactsRef.child("users/"   auth.uid   "/('#name')")
.set({ a1: $('#name').val(), })

I've looked at this too but it wasn't helpful enter image description here

CodePudding user response:

If I correctly understand your question, you need to do:

contactsRef.child("users/"   auth.uid   "/"   $('#name').val())
.set({ a1: $('#name').val()});
  • Related