[nycphp-talk] call javascript function from php

Michele Waldman mmwaldman at
Tue Jan 20 08:35:49 EST 2009

One final thing.  Is it calling the function and just not working or not
calling the function?

Quick test. Put and alert statement at the top of the function to see if
it's actually called.

Cause that function doesn't look like it works to me.



From: talk-bounces at [mailto:talk-bounces at] On
Behalf Of chad qian
Sent: Monday, January 19, 2009 11:05 PM
To: talk at
Subject: [nycphp-talk] call javascript function from php


I want to call javascript function from php.But I fail.
Here is the source code,any help?Thanks!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
   <script language="javascript">
     function chng(c_img) { 
  img1 = "images/bullet_green.png"; 
     img2 = "images/bullet_red.png"; 
     if (document[c_img].src.indexOf(img1)!= -1) document[c_img].src = img2;

     else document[c_img].src = img1; 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php echo "<a href=\"javascript:chng('img')\"><img
src=\"images/bullet_green.png\" name=\"img\"></a>" ;?>


Windows LiveT: Keep your life in sync. Check it out.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the talk mailing list