Jump to content

Ajax, php and javascript


epolan

Recommended Posts

Hi everyone

 

Just a quick one.. i've created an ajax script to read a content from a php file using innerhtml. Inside the php file, there is a javascript code which is generated using php. The thing is, the javascript code could not be executed when the php file is loaded but when i open the php file itself, the javascript can be execute. Which mean, there is no problem with my javascript. Is there any solution for my problem??

Link to comment
https://forums.phpfreaks.com/topic/77342-ajax-php-and-javascript/
Share on other sites

yes..the script is in php file but not using onload event. the script is for image gallery where i query from the database.

 

Here's the script in the php file:-

 

<script language="JavaScript" type="text/javascript"><!--

//thumbnail script

<?

for ($i=0;$i<count($gambar);$i++) {

echo "image$i =new Image();\n";

}

for ($i=0;$i<count($gambar);$i++) {

 

echo "image$i.src = \"photos/$gambar[$i]m.jpg\"\n";

}

for ($i=0;$i<count($gambar);$i++) {

 

echo "document.images['pimage$i'].src=image$i.src;\n";

}

 

 

 

for($i=0;$i<count($gambar);$i++){

$caption[$i] = $caption[$i];

?>

 

 

function image_click(clicks) {

<?

for ($i=0;$i<count($gambar);$i++) {

echo "if(clicks==$i){

document.images['large'].src=image$i.src;

 

}\n";

}

?>

}

 

 

 

function LoadGallery(larger,captionText)

{

 

document.getElementById(larger).innerHTML=captionText;

}

 

</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.