Depending on the structure of your data, you may get a link to the person you want before update .
So, if your data looks something like this:
{ "remarks" : { ... }, "person" : { "123456" : { "name" : "foo", ... "blah" : "bar" }, ... } }
And document.getElementById("Person").value gives you 123456 , you can get the link:
var personRef = ref.child("person").child(_person);
Then you want to know if it exists, and if so, update it:
personRef.once('value', function(snapshot) { if( snapshot.val() === null ) { } else { snapshot.ref().update({"postID": postID}); } });
source share