I'm creating a page that should read data from the database, display it as a table, and allow row-wise editing of the entries (using AJAX calls). Here are brief code snippets where the problem comes -
Javascript:
function editParam(bname, button) {
alert(bname); //this part doesn't happen, the error on console comes up before it
tr = button.parentNode;
while (tr && tr.nodeName.toUpperCase() !== "TR" && tr.nodeName.toUpperCase() !== "BODY") {
tr = tr.parentNode;
}
if (!tr || tr.nodeName.toUpperCase() !== "TR") {
return;
}
//some more code
}
PHP:
//get $row_users['Name']
while ($row_users = mysqli_fetch_array($results)) {
echo "<form method='POST'> //some <tr><td></td></tr>
<button onclick='editParam(".$row_users['Name'].", this)'>Edit</button>
</form>";
}
My data in the column Name is like "B1", "C2", etc.
Error onclick of button : B1 is not defined.
While running the code for other text or numbers, it worked fine. So I understand that my problem has to do with the datatype. However, I do not know how resolve the same.
Any suggestions would be much appreciated, thanks!