Javascript slideshow

perer

Registered
Здравейте!
Някой може ли да ми даде Java Script за слайдшоу със снимки от дадена папка. Искам всички снимки от папката да се въртят. :)

Благодаря!
 
Доколкото ми е известно това само с JS няма да стане. Ако нямаш нищо против да включиш и малко PHP, мога да ударя едно рамо :)
 
Ами, да нямам проблем да включа PHP :)

Много ще съм ти благодарен!
 
Код:
<body>
<img id="myPictureId" src="" alt=""/>
<?php
$arrayElem = '';
$dir = opendir('.');
while ($file = readdir($dir)){
	if($file == '.' || $file == '..'){continue;}
	$info = explode('.', $file);
	$file_ext = strtolower($info[count($info)-1]);
	if($file_ext == 'jpg' || $file_ext == 'jpeg' || $file_ext == 'png' || $file_ext == 'gif'){
		if(!$arrayElem){$arrayElem = "'$file'";}
		else{$arrayElem .= ",'$file'";}
	}
}
closedir($dir);
?>
<script type="text/javascript">
	var oPicture = document.getElementById('myPictureId');
	var nInterval = 1000;
	var pictureList = new Array(<?php echo $arrayElem;?>);
	var index = -1;
	var oInterval = null;

	function sshow(){
		oInterval = setInterval("slideshow()", nInterval);
	}

	function slideshow(){
		index++;
		if (index == pictureList.length){
			index = 0;
		}
		oPicture.src = pictureList[index];
	}
	sshow();
</script>
</body>
Това е съвсем базов вариант, който можеш да си пригодиш според нуждите.
 
Добавих папката и още един формат, но нищо не излиза
Нещо друго трябва ли да направя? :P
Ето как стана:
Код:
<img id="myPictureId" src="" alt=""/>

<?php
$arrayElem = '';
$dir = opendir('images/Pictures');
while ($file = readdir($dir)){
   if($file == '.' || $file == '..'){continue;}
   $info = explode('.', $file);
   $file_ext = strtolower($info[count($info)-1]);
   if($file_ext == 'jpg' || $file_ext == 'JPG' || $file_ext == 'jpeg' || $file_ext == 'png' || $file_ext == 'gif'){
      if(!$arrayElem){$arrayElem = "'$file'";}
      else{$arrayElem .= ",'$file'";}
   }
}
closedir($dir);
?>
<script type="text/javascript">
   var oPicture = document.getElementById('myPictureId');
   var nInterval = 1000;
   var pictureList = new Array(<?php echo $arrayElem;?>);
   var index = -1;
   var oInterval = null;

   function sshow(){
      oInterval = setInterval("slideshow()", nInterval);
   }

   function slideshow(){
      index++;
      if (index == pictureList.length){
         index = 0;
      }
      oPicture.src = pictureList[index];
   }
   sshow();
</script>
 
Това strtolower($info[count($info)-1]) обезсмисля това $file_ext == 'JPG'.
А проблема ти мисля че е тук
oPicture.src = 'images/Pictures/'+pictureList[index];
 

Back
Горе