Results 1 to 3 of 3

Thread: Random Javascript Script Problem

  1. #1
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default Random Javascript Script Problem

    Im using this script:
    Code:
    <script>
    
    var contents_b=new Array()
    
    //1) Specify content(s) to display and rotate (extend as desired)
    contents_b[0]='<img border="0" src="images/pies.gif"><img src="/images/1arrow.gif" width="3" height="6" align="absmiddle"> <font>Pies</font>'
    contents_b[1]='<img border="0" src="images/breads.gif"><img src="/images/1arrow.gif" width="3" height="6" align="absmiddle"> <font>Breads</font>'
    contents_b[2]='<img border="0" src="images/cakes.gif"><img src="/images/1arrow.gif" width="3" height="6" align="absmiddle"> <font>Cakes</font>'
    
    var the_one_b
    var y=0
    var spacing_b=" "
    
    while (y<contents_b.length){
    the_one_b=Math.floor(Math.random()*contents_b.length)
    if (contents_b[the_one_b]!="_selected!"){
    document.write(contents_b[the_one_b]+spacing_b)
    contents_b[the_one_b]="_selected!"
    y++
    }
    }
    
    </script>
    and I need the arrow & text to be under the picture.

    Page with the problem

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I am by no means a JS person.. but I was able to get close, only thing is that the whole thing is down left side, instead of across the top:

    Code:
    <script>
    
    var contents_b=new Array()
    
    
    contents_b[0]='<p><img border="0" src="images/pies.gif"><br><img src="/images/1arrow.gif" width="3" height="6" align="absmiddle"> <font>Pies</font></p>'
    
    contents_b[1]='<p><img border="0" src="images/breads.gif"><br><img src="/images/1arrow.gif" width="3" height="6" align="absmiddle"> <font>Breads</font></p>'
    
    contents_b[2]='<p><img border="0" src="images/cakes.gif"><br><img src="/images/1arrow.gif" width="3" height="6" align="absmiddle"> <font>Cakes</font></p>'
    
    var the_one_b
    var y=0
    var spacing_b=" "
    
    while (y<contents_b.length){
    the_one_b=Math.floor(Math.random()*contents_b.length)
    if (contents_b[the_one_b]!="_selected!"){
    document.write(contents_b[the_one_b]+spacing_b)
    contents_b[the_one_b]="_selected!"
    y++
    }
    }
    
    </script>
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    well I need the pictures side by side and the text under it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •