Passing parameters to Javascript using PHP

Posted by ayush on Stack Overflow See other posts from Stack Overflow or by ayush
Published on 2010-06-10T20:00:00Z Indexed on 2010/06/10 20:13 UTC
Read the original article Hit count: 232

Filed under:
|

I have the following line of code:

<a href="javascript:;" onClick="tweeet('myid')">My Tweets!</a>

Now while this is working perfectly fine the following line is not:

<a href="javascript:;" onClick="tweeet(<?php echo 'myid'; ?>)">My Tweets!</a> 

Can anyone help me out why it is not working and suggest any changes? The variable I want to pass to the Javascript function is a PHP variable. I have tried the PHP with single quotes and double quotes but it is not working.

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript