Rotating image JavaScript not working - Anyone able to help?

Discussion in 'JavaScript' started by raay, Jan 7, 2006.

  1. #1
    Hi all,

    I've got this JavaScript working at a site but can't seem to get it working when I "cut and paste" it into a php include file at another site.

    Any chance that someone might be able to tell me what I am doing wrong?
    Missing some script instructions?

    ++++++++++++++++++++++++++++++++++++
    <table border="0" cellpadding="0" cellspacing="0" align="right" width="350"><tr><td align="right">
    <br><br><br>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    // Set up the image files to be used.
    var theImages = new Array() // do not change this
    // To add more image files, continue with the
    // pattern below, adding to the array.

    theImages[0] = 'http://www.shoesuk.co.uk/images9/womens-shoes-9.jpg'
    theImages[1] = 'http://www.shoesuk.co.uk/images9/mens-shoes-1.jpg'
    theImages[2] = 'http://www.shoesuk.co.uk/images9/mens-shoes-2.jpg'
    theImages[3] = 'http://www.shoesuk.co.uk/images9/shoes-uk.jpg'
    theImages[4] = 'http://www.shoesuk.co.uk/images9/shoes-uk-0.jpg'
    theImages[5] = 'http://www.shoesuk.co.uk/images9/sports-shoes-1.jpg'


    // do not edit anything below this line

    var j = 0
    var p = theImages.length;
    var preBuffer = new Array()
    for (i = 0; i < p; i++){
    preBuffer = new Image()
    preBuffer.src = theImages
    }
    var whichImage = Math.round(Math.random()*(p-1));
    function showImage(){
    document.write('<img border="0" width="312 height="317" src="'+theImages[whichImage]+'">');
    }

    // End -->
    </script>
    </td></tr></table>
    ++++++++++++++++++++++++++++++++++++++++++++++++++

    Thanks all.
     
    raay, Jan 7, 2006 IP
  2. cytech

    cytech Guest

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    are you calling the javascript function showimage?


    
    function showImage(){ 
    document.write('<img border="0" width="312 height="317" src="'+theImages[whichImage]+'">'); 
    } 
    
    window.onload=showImage();
    
    // End --> 
    
    
    Code (markup):
     
    cytech, Jan 8, 2006 IP
  3. raay

    raay Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks cytech.
    Have solved it!
     
    raay, Jan 9, 2006 IP