syntax error I'm not finding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tpgames
    Contributor
    • Jan 2007
    • 783

    syntax error I'm not finding

    I can't get this script to recognize that the image name is
    Image53.jpg, Image54.jpg, etc. instead of 53.jpg, 54.jpg.
    What am I doing wrong? I'm trying to not have to change a thousand image names. :D

    Code:
    //change x=0 to x=1 change current= 0 to current = 1 Works!
    
    // The 1 = the first image number for both X and Current!
    
    imgName = new Array()
    for (x=53; x<=100; x++) {
    imgName[x] = x
    }
    
    contextPath = " http://www.tpgames.net/gaming/4/2/tpgames/zwp/tce/";
    extensionJ = "Image";
    extensionK = ".jpg";
    
    current = 47;      //ONLY CHANGE THIS NUMBER! MAKE 10 PER STORY
    
    //window.onload = randomizeImage
    
    function randomizeImage() {
    changeImg()
    }
    
    function changeImg() {
    holder = document.getElementById("bgHolder");
    holder.style.background="url(" + contextPath + extensionJ + imgName[current] + extensionK + ")";
    
    if (current < imgName.length-1) {	current = current+1 }
    else { current = 1 }
    setTimeout('randomizeImage()',1000);
    }
    
    setTimeout('randomizeImage()',1000);//only is executed on pageload
    function randomizeImage() {
    holder = document.getElementById("bgHolder");
    if (holder==null){
    setTimeout('randomizeImage()',1000);}
    else{
    changeImg();
    }
    }
    Last edited by tpgames; Jun 21 '09, 06:19 PM. Reason: more data needed.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    There's no need for the array. Just use the current number in place of the array.

    What's the error message and on which line?

    Comment

    • tpgames
      Contributor
      • Jan 2007
      • 783

      #3
      I don't get an actual error message. It doesn't even recognize...Hol d on!
      I think I might have found the error. The silly URL to the JS file isn't even correct! LOL If I ever figure out how to compare A to A to B and read that B does not = A, I will be so happy! :D I'll post back in minute.

      Comment

      • tpgames
        Contributor
        • Jan 2007
        • 783

        #4
        Fixed! I had flipped the folders /js/ and /e/ around when I typed it in and when I checked to see if it was typed in correctly, I didn't see that it wasn't. Thats always the first thing I check because its usually the error. *twitch eyes*
        Wrong: ~.net/css/js/e/tce1.js
        Correct: ~.net/css/e/js/tce1.js

        I thought the syntax error was in my JS. Silly me! I should have known that I wasn't see the links correctly. Oh well, at least I knew that there was something I wasn't seeing correctly. LOL
        Thanks!

        Comment

        Working...