<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I don't see the 'img' variable declared anywhere. Is it a JavaScript or PHP ($img) variable?<br>In the former case, PHP is not needed. <br>Assuming the latter case, try this:<br>(plain HTML here)<br><br>&lt;img src="images/bullet_green.png" name="&lt;?php echo $img; ?&gt;" <br>&nbsp;&nbsp;&nbsp;&nbsp; onclick="chng('&lt;?php echo $img; ?&gt;')" /&gt;<br><br><br>--- On <b>Mon, 1/19/09, chad qian <i>&lt;nynj.tech@hotmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: chad qian &lt;nynj.tech@hotmail.com&gt;<br>Subject: [nycphp-talk] call javascript function from php<br>To: talk@lists.nyphp.org<br>Date: Monday, January 19, 2009, 11:05 PM<br><br><div id="yiv1794954754">

<style>
#yiv1794954754 .hmmessage P
{
margin:0px;padding:0px;}
#yiv1794954754 {
font-size:10pt;font-family:Verdana;}
</style>
I want to call javascript function from php.But I fail.<br>
Here is the source code,any help?Thanks!<br>
&nbsp;<br>
chad<br>
&nbsp;<br>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a rel="nofollow" target="_blank" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"&gt;<br>&lt;html xmlns="<a rel="nofollow" target="_blank" href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"&gt;<br>&lt;head&gt;<br>&nbsp;&nbsp; &lt;script language="javascript"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; function chng(c_img) { <br>&nbsp; img1 = "images/bullet_green.png"; <br>&nbsp;&nbsp;&nbsp;&nbsp; img2 = "images/bullet_red.png"; <br>&nbsp;&nbsp;&nbsp;&nbsp; if (document[c_img].src.indexOf(img1)!= -1) document[c_img].src = img2; <br>&nbsp;&nbsp;&nbsp;&nbsp; else document[c_img].src = img1; <br>&nbsp; }<br>&nbsp;&nbsp; //}<br>&nbsp;&nbsp; &lt;/script&gt;<br>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br>&lt;title&gt;Untitled Document&lt;/title&gt;<br>&lt;/head&gt;<br>
&lt;body&gt;<br>
&lt;?php echo "&lt;a href=\"javascript:chng('img')\"&gt;&lt;img src=\"images/bullet_green.png\" name=\"img\"&gt;&lt;/a&gt;" ;?&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br><br><hr>Windows Live™: Keep your life in sync. <a rel="nofollow" target="_blank" href="http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009">Check it out.</a> 
</div><pre>_______________________________________________<br>New York PHP User Group Community Talk Mailing List<br>http://lists.nyphp.org/mailman/listinfo/talk<br><br>http://www.nyphp.org/show_participation.php</pre></blockquote></td></tr></table>