'innerHTML pass in variable to function
I have a table which is pulling data from firebase:
r.insertCell(23).innerHTML = doc.data().username;
r.insertCell(24).innerHTML = doc.data().uid;
r.insertCell(25).innerHTML ='<button onclick="activateUserInTable('+doc.data().uid +')">Activate User</button>';
I have a function:
function activateUserInTable(userId) {
db.collection("users").doc(userId).update({
activated: 1,
});
}
I have a button in my table:
r.insertCell(25).innerHTML ='<button onclick="activateUserInTable('+doc.data().uid +')">Activate User</button>';
Im trying to pass doc.data().uid into the button above in the table.
But this doesn't seem to work. This function does work if its outside the table and i manually pass in a uid. I want to be able to pass in the data from firebase into the function while the button is in the table.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
