I am defining onclick event to a a href based on a condition
Here's my script:
<script>
function comment_pop(id)
{
alert(id);
$('#login_ret_url').val('<?php echo base_url();?>idea/view_idea/'+id+'?action=comment');
ShowModalPopup('div_login');
}
</script>
<div class="rate_image">
<a href="<?php if(isset($_SESSION['logged_user']))
echo base_url().'idea/view_idea/'.$row['idea_slug'].'?action=comment';
else
echo 'javascript:void(0)';?>"
<?php if(!isset($_SESSION['logged_user']))
echo "onclick='comment_pop(".$row['idea_slug'].");'";?>>
<?php echo $total_comment[$key][0]['total_cont'];?>
</a>
</div>
The problem rises in the line
echo "onclick='comment_pop(".$row['idea_slug'].");'";?>>
I am trying to concat the function with the variable so that I can send parameter to the JavaScript function but it's not working.
I think I need to use some escape parameters but I am really new to this.
$row['idea_slug']? And what does the source show afteronclick=?