1

I have the code for a jQuery image slider that pulls from a directory. My client will just be dropping in images into the folder and deleting them without my knowledge. Right now it requires I put in a number (under 'numslides') for how many slides they'll have. With it constantly changing what value do I put it?

(function($){
var directorySlider = function(element, options)
{
   var elem = $(element),
       obj = this,
       elemId = elem[0].id;

   // Merge config settings
   var config = $.extend({
       animation: 'fade',
       filebase: 'slide_',
       extension: 'jpg',
       speed: 1000,
       timeout: 4000,
       directory: '/path/images/',
       numslides: 3,
       height: 778,
       width: 448
   }, options || {});

This is the PHP code on my page:

$(document).ready(function(){
$('.directorySlider').directorySlider();
   });

Someone suggested this code below and the top code is what's in my js file. How would I implement this:

 $.get('numberoffiles.php', function(data) {
   alert(data);
   });
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Jake
  • 25
  • 1
  • 6
  • Why dont you just count the no of files, in your case its images. This SO question can help u http://stackoverflow.com/questions/11489738/how-do-i-count-files-in-a-directory-using-jquery – dreamweiver Apr 26 '13 at 14:18
  • I edited the original listing. My PHP ability is limited. I can tweak what exists but that's about it. – Jake Apr 26 '13 at 14:38
  • 3
    Refer this link http://stackoverflow.com/questions/6867149/how-to-count-number-of-files-in-a-directory-using-php which will give you number of files. you can put this code into numberoffiles.php and on success of $.get('numberoffiles.php', function(data) { //Here call your slider function and pass this count into your script as parameter. }); – Kamal Joshi Apr 26 '13 at 15:54

0 Answers0