The folowing code should show me the results of the selected ID :
<form id="<?= $blog_id ?>" method="post" action="show.php">
<input type="hidden" name="blog_id" value="<?= $blog_id ?>">
<input type="hidden" name="blog_title" value="<?= $blog_title ?>">
<input type="hidden" name="blog_date" value="<?= $blog_date ?>">
<input type="hidden" name="blog_content" value="<?= $blog_content ?>">
Click <a href="#" onclick="document.getElementById('<?= $blog_id ?>').submit();">here</a> to see (<?= count($blog_comments) ?>) comments.
</form>
But when i click the link, it does nothing (Does not lead me to show.php).
However, if i change onclick="document.getElementById('<?= $blog_id ?>') To onclick="document.getElementById('test') (And also the other id).
It leads me to show.php, but shows me the highest ID.
Why do i need the id to be a variable? because it is in a loop, and when i click the link, i want to get the correct information from the selected id.
I looked at my console (inspect element), and it says:
Uncaught TypeError: document.getElementById(...).submit is not a function
However i don't know how to fix this.
obj.addEventListener().