0

so i found this script which is perfect.. it loads all my content from my ftp and randomizes them.... BUT you always have to refresh the site.. my question now is.. how can i add a fixed frame or just a button which allows me to refresh the pictures instead of the whole page..
[already got an refrsh button.. but like i sad..for the whole page -.- not just the content.]

Thanks for any help and greets from germany.

<p align="center"><script type="text/javascript">
function random_imglink(){

<?php
function returnimages($dirname="./content/") {
   $pattern="\.(jpg|jpeg|png|gif|bmp)$";
   $files = array();
   $curimage=0;
   if($handle = opendir($dirname)) {
       while(false !== ($file = readdir($handle))){
               if(eregi($pattern, $file)){
                 echo 'myimages[' . $curimage .']="' . $dirname . $file . '";' . "
";
                 $curimage++;
               }
       }

       closedir($handle);
   }
   return($files);
}

echo "var myimages=new Array();" . "
";
returnimages();
?>

var ry=Math.floor(Math.random()*myimages.length)
document.write('<img src="'+myimages[ry]+'" border=0>')
}
random_imglink()
</script>
<br>
<a href="javascript:document.location.reload();"
ONMOUSEOVER="window.status='Refresh'; return true"
ONMOUSEOUT="window.status='ah... that was good'">
<img src="images/refresh_button.jpg"
width="100" height="50" border="0" /></a>
</p>
3
Contributors
6
Replies
16
Views
3 Years
Discussion Span
Last Post by noelthefish
0

PHP is server side which means there is no way to actually refresh the data without reloading the page unless you use AJAX which is releativley complicated, and it's more of a JS thing so you'd be better of asking there.

Hope this helps!

0

ah dang it!

thought of something like this would come up, but thx for the quick answer!!

0

If you think this question has been sufficently answered, please click the button at the bottom that says 'Mark question solved' and if possible, upvote the answer that helped you. This means that people can easily see your issue has been resolved. Thanks!

0

You have stored all the images in an array so all you need to do is to run the same 2 lines of code and it will pick another random image.it's line 28 and 29.

0

You have stored all the images in an array so all you need to do is to run the same 2 lines of code and it will pick another random image.it's line 28 and 29.

The OP doesn't want a way to generate another set of images, they want to be able to get a new set replacing the old one without refreshing the whole page.

0

Choosing another random array position number and then writing it to the document does not generate a new set of images it just changes the image there without refreshing the page which is my understanding of what they need

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.