Jump to content

Recommended Posts

Guys, I'm creating a javascript slideshow which works perfectly if the jpgs are prescribed as below.

 

<script type="text/javascript">

<!--

var image1=new Image()

image1.src="florida1.jpg"

var image2=new Image()

image2.src="florida2.jpg"

var image3=new Image()

image3.src="florida3.jpg"

//-->

</script>

 

but instead of using the 3 prescribed florida jpgs I wanted to echo the jpg name as php variables what's the syntax??

 

My coding is currently:

 

$xx=0;

$xxx=1;

while($xx < $totalslide) {

$preload = $preload."var image".$xxx."=new Image()";

$preload = $preload." image".$xxx.".src=".$slideimage[$xx]." ";

$xxx++;

$xx++;

}

 

When echoed, $preload produces:

 

var image1=new Image() image1.src=members/a/alpha01/Animpub/pubanalpha0118117.jpg var image2=new Image() image2.src=members/a/alpha01/Animpub/pubanalpha0118128.jpg var image3=new Image() image3.src=members/a/alpha01/Animpub/pubanalpha0118151.jpg

 

This doesn't work with the remainder of the slideshow script presumably because the jpg path isn't wrapped in double quotes. So how can I get the double quotes into the script???????

 

 

Link to comment
https://forums.phpfreaks.com/topic/50917-phpjava/
Share on other sites

You can reduce the code in the loop a little by doing:

<?php
$preload = array();
for($xx = 0;$xx < $totalslide; $xx++) {
   $xxx = $xx +1;
   $preload[] = 'var image'.$xxx.'=new Image()';
   $preload[] = 'image' . $xxx . '.src="' . $slideimage[$xx] . '";';
}
echo implode("\r\n",$preload)."\r\n";
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/50917-phpjava/#findComment-250440
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.