You are here: Using javascript function from php « PHP « IT news, forums, messages
Using javascript function from php

Posted by b on 09/25/95 11:10

Hi,

I am just learning php, and am currently converting some jsp pages to ph=
p. =

I used the follwing code in jsp to toggle between two images

<SCRIPT type=3D"text/javascript" language=3Djavascript>
function toggle(imagename,src1,src2){
if(document.images && document.images[imagename])
{
image1=3Dnew Image;
image1.src=3Dsrc1;
if(document.images[imagename].src !=3D =

image1.src){document.images[imagename].src =3D image1.src}
else{document.images[imagename].src=3Dsrc2}
}
}
</SCRIPT>

start code snippet.............
out.println("<A");
out.println("onclick=3D\"toggle('" + child + "image','images/" + type =

+ ".jpg','images/" + childimg "');return(false);\"");
out.println("><img src=3D'images/" + type + ".jpg' alt=3D'' name=3D" + c=
hild =

+ "image></a>");
out.println("<input type=3Dhidden name=3D" + child + " value=3D'" + chil=
dimg =

+ "'>");
end code snippet...............

I have tried many different ways to achieve this in php, but nothing =

works. This is my latest attempt

start code snippet.............
print("<A href=3D\"javascript:;\" onclick=3D");
echo "\"if(document.images && document.images[" . $child . "image])\n";
echo " {\n";
echo " image1=3Dnew Image;\n";
echo " image1.src=3Dimages/$type.jpg;\n";
echo " if(document.images[" . $child . "image].src !=3D =

image1.src){document.images[" . $child . "image].src =3D image1.src}\n";=

echo " else{document.images[" . $child . "image].src=3Dimages/$childimg}=
\n";
echo " }\n";
echo "};\n";
echo "return(false);\">\n";
print("<img src=3D'images/$type.jpg' alt=3D'' name=3D" . $child . =

"image>\n</a>\n");
print("<input type=3Dhidden name=3D$child value=3D'$childimg'>\n");
end code snippet.............

Could someone please let me know how to do this

Cheers
Barb

-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация