I am using a PHP script to get data from a MySQL server. Once I get that data, I'm looping through it (still in PHP) and using it to output a series of datasets each with their own button
$returnString = '<form action="/iOS/action_page.php" method="post">';
// output data of each row
while($row = $result->fetch_assoc()) {
$echoString = '<h2>Study Title: '. $row['title'] . '</h2>';
$echoString .= '<h3>Study Nickname: ' . $row['nickname'] .'</h3>';
$echoString .= '<button type="button" id="login-button" Onclick="setUrl(' . rawurlencode($row['title']) . ')"> View Tasks </button>';
echo $echoString;
}
(The "title" of the row is a string that may or may not have spaces and such, like "Hello%20World")
The 'setUrl' function sits outside of the PHP brackets and just tries to move to a new page:
<script>
function setUrl(tableTitle) {
window.location.href = "https://exampleWebsite.com/PHPPage.php?id=".concat(tableTitle);
};
</script>
But every time I try to click a button, I get this error popping up in the console:
SyntaxError: No identifiers allowed directly after numeric literal
The only way I can get it to work is by passing in an Integer rather than a string, but that doesn't work for my use case.