2011-04-28 10 views
0

안녕하세요 사람들은 운동을 할 수없는 문제가있어서 imageswitch을 사용하여 슬라이드 쇼를 만듭니다.jquery 슬라이드 쇼, 색인이 진행되지 않습니다.

난 다음 JQuery와 있습니다

// set up slideshow 
    var IdxTR = <?php echo($totalRows_rs_gallery); ?>; 
    var Idx =0; 

    var ChangeImage = function(){ 
     console.log('Idx: '+Idx+' - IdxTR: '+IdxTR+' Img: '+$(".SlImage").eq(Idx).attr("rel")); 
     //If the image still animating, stop it and start the new one 
     $("#mainImage").ImageStop(true,true); 
     $("#mainImage").ImageSwitch({NewImage: $(".SlImage").eq(Idx).attr("rel")});  
     //Set the next image will be display 
     Idx = Idx++; 
     console.log('AFTER --- Idx: '+Idx+' - IdxTR: '+IdxTR+' Img: '+$(".SlImage").eq(Idx).attr("rel")); 
     if(Idx>IdxTR){ 
      Idx = 0; 
     } 
     //Start preload the next image 
     $.ImagePreload($(".SlImage").eq(Idx).attr("rel")); 
    }; 
    var StartSlideShow = function(){ 
     IntervalKey = setInterval(ChangeImage,1000); 
    }; 
StartSlideShow(); 

을 내 HTML에 내가있다 :

<div id="topcontainer"> 
<img id="mainImage" src="images/gallery/<?php echo $row_rs_gallery['image_gly']; ?>" /> 
<?php do { ?> 
    <div class="SlImage" rel="images/gallery/<?php echo $row_rs_gallery['image_gly']; ?>"/> 
    <?php } while ($row_rs_gallery = mysql_fetch_assoc($rs_gallery)); ?> 
</div> 

첫 CONSOLE.LOG 출력 : IDX : 0 - IdxTR : 8 IMG : 이미지/갤러리 /alison.jpg

두 번째 consloe.log는 표시되지 않으며 ChangeImage() 함수가 다시 실행되면 idx가 고급 상태가 아니며 첫 번째 console.log는 동일한 내용을 출력합니다. Idx : 0 - IdxTR : 8 Img : images/gallery/alison.jpg

색인이 향상되지 않은 이유는 무엇입니까? 또는 두 번째 console.log가 실행되지 않는 이유는 무엇입니까?

test page is here

답변

1

당신은 아마 당신의 자바 스크립트가 처음 만드는 오류를 수정하고자합니다. 계속 출력 :

Idx: 0 - IdxTR: 8 Img: images/gallery/alison.jpg 
jquery-1.4.3.min.js:55Uncaught TypeError: Cannot read property 'handler' of undefined 
information3.php:20Idx: 0 - IdxTR: 8 Img: images/gallery/alison.jpg 
jquery-1.4.3.min.js:55Uncaught TypeError: Cannot read property 'handler' of undefined 
information3.php:20Idx: 0 - IdxTR: 8 Img: images/gallery/alison.jpg 

등등. 오류는 CONSOLE.LOG 후 것 같다,하지만 당신하고 Idx ++ 전에, 그것은 0에서 변경되지 않습니다, 그것은 당신이 무엇을보고 있는지

또한 :
지금은 혼란스러워지고있어 (커피를 시작합니다). 그러나 이것을 확인하십시오. :
간단한 Idx+1 방법이나 ++Idx을 시도하십시오. this page에서

(아주 임의 페이지, 나는 인정)

var a = 5; 
    b = a++; 
    (b contains the initial value of a, which is 5. 
    a, on the other hand is now equal to 6) 

    var a = 5; 
    c = ++a; 
    (In this case, JavaScript first adds 1 to a, changing 
    its value to 6. This value is returned to c. 
    Thus, c = 6) 

내가하시기 바랍니다 귀하의 경우에는 무슨 일이 일어나고 있는지 알고 있지만, 간단한 +1 방법을 시도하지?

+0

안녕하세요, 방화범이 끌리는 다른 오류를 볼 수 없습니까? 나는 console.log와 Idx ++ 사이의 모든 것을 주석 처리했는데, 두 번째 console.log는 이제 실행되지만 인덱스는 여전히 고급입니다. http://new.camerich.co.uk/information4.php?id_sec=2 –

+1

에 몇 가지 stuffz를 추가했습니다. 이 시도? – Nanne

+0

멋지다. 그 커피를 잡을 수있다 ... changed Idx = Idx + 1; 이제 인덱스가 바뀌고 trhe 다른 비트를 볼 시간이되었습니다. 그 오어 에러를 얻기 위해 무엇을 사용 했습니까? 나는 방화 광 1.62에 있는데 그것은 나타나지 않는다. –

관련 문제