simple js problem - i think

Discussion in 'JavaScript' started by tony84, Sep 15, 2008.

  1. #1
    Could anyone help spot the problem witht he code below, i have put in bold the line i think has the problem but im not 100% sure

    <script language="JavaScript1.2">
    
    var howOften = 7; //number often in seconds to rotate
    var current = 0; //start the counter at 0
    var ns6 = document.getElementById&&!document.all; //detect netscape 6
    
    // place your images, text, etc in the array elements here
    var items = new Array();
        [B]items[0]="<a href='http://.co.uk/view_room.php?id=43'><img src='http://.co.uk/photos/43-1-1221452071.jpg' width="120' height='100' border='0'> The G, Mer</a>";[/B] 
        items[1]="<a href='http://.co.uk/view_room.php?id=43'><img src='http://.co.uk/photos/43-1-1221452071.jpg' width="120' height='100' border='0'> The y, Mncer</a>"; 
    
    
    function rotater() {
        if(document.layers) {
            document.placeholderlayer.document.write(items[current]);
            document.placeholderlayer.document.close();
        }
        if(ns6)document.getElementById("placeholderdiv").innerHTML=items[current]
            if(document.all)
                placeholderdiv.innerHTML=items[current];
    
        current = (current==items.length) ? 0 : current + 1; //increment or reset
        setTimeout("rotater()",howOften*1000);
    }
    window.onload=rotater;
    //–>
    </script>
    Code (markup):

     
    tony84, Sep 15, 2008 IP
  2. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You problem is : width="120'

    Should be width='120' .

    Same problem on the next line.
     
    LogicFlux, Sep 15, 2008 IP
    tony84 likes this.
  3. tony84

    tony84 Well-Known Member

    Messages:
    1,864
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Still doesnt seem to be working :S
     
    tony84, Sep 16, 2008 IP
  4. qprojects

    qprojects Peon

    Messages:
    1,901
    Likes Received:
    103
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Should work.
     
    qprojects, Sep 16, 2008 IP
    tony84 likes this.
  5. tony84

    tony84 Well-Known Member

    Messages:
    1,864
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    140
    #5
    cheers, all working now
     
    tony84, Sep 16, 2008 IP
  6. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #6
    I guess, this is missing somewhere in <BODY>

    <div id="placeholderdiv"></div>

    btw. maybe you need also set some dimensions : <div id="placeholderdiv" style="width:120px;height:120px;border:1px solid black;"></div>
     
    lp1051, Sep 16, 2008 IP
    tony84 likes this.
  7. tony84

    tony84 Well-Known Member

    Messages:
    1,864
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    140
    #7
    hmm, maybe the size could be better placed in div instead of each picture.

    I didnt think of that. Thanks for the suggestion +rep to everyone on this thread
     
    tony84, Sep 16, 2008 IP
    qprojects likes this.