This question already has an answer here:
I'm trying to use a PHP-variable as a function argument, to change classNames of HTML elements by concatenating the function argument to a string.
I get the error: Uncaught SyntaxError: Unexpected end of input
its refering to this line, the 4 inputs that currently are spawned:
<input type="button" id="2019-04-23 11:12:14"
onclick="get_db("professor");" value="2019-04-23 11:12:14" /><br><input
type="button" id="2019-04-23 11:12:19" onclick="get_db("professor");"
value="2019-04-23 11:12:19" /><br><input type="button" id="2019-04-23
11:12:21" onclick="get_db("professor");" value="2019-04-23 11:12:21" /><br>
</div>
when I look in the debugger, it says get_db (professor) which is the correct username though.
Here is a DIV that I would like to hide at the press of the input button:
<div id="professorshistory" class="tab-pane fade">
<p><?php writeDate('22'); ?></p>
</div>
</div>
Here is the PHP. Rad means Row (swedish).
$username = $rad['username'];
$json = json_encode($username);
echo '<input type="button" id="'.$rad['dateofpost'].'"
onclick="get_db('.$json.')" value="'.$rad['dateofpost'].'" >
gheh </input>';
here is the script. the point would be that the function argument concatenates with "shistory", so if the argument gets the username "professor" from the sql database, then the function would reference the document with the ID of "professorshistory", and that hides the tab.
function get_db(usernames){
document.getElementById(usernames + "shistory").className = "tab-pane hide "
</div>