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
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.