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>

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!

ah dang it!

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

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!

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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.