I have a problem, I'm trying to dynamically add some html via javascript, and the html has a js function that's supposed to trigger when it's clicked, but I keep getting this error no matter what I do Uncaught SyntaxError: Unexpected token }
Has anyone had this problem before? This has eluded me..
My code is :
<?php
foreach($folder_info as $show)
{
echo '<table><tr>';
echo '<span class="glyphicon glyphicon-folder-close" onclick="'.site_url().'/gallery/upload_images" aria-hidden="true" style="font-size:100px;"></span><br/>'.$show['folder_name'];
echo '</tr></table>';
}
?>
Where am I getting Wrong? Can Anyone help me to segment the line with php and html correctly..
Just try the following, it will work, I tried in my local server. You should be careful while doing quotes[single/double], to avoid the mismatch of php and html tags.
I have modified your code with the <a>
tags..!
<?php
foreach($folder_info as $show)
{?>
<table><tr>
<a class="glyphicon glyphicon-folder-close" href="<?php echo site_url()?>/gallery/upload_images" aria-hidden="true" style="font-size:100px;"></span></a><br/><?php echo $show['folder_name'];?>
</tr></table>
<?php }
?>