SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2003
    Location
    California
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    link on images in an image randomizer

    I have an image randomizer and I need to put links on the images, how can I do that? This is the site where the randomizer is http://www.nenastran.com/testingsite/ and it is the large image on the left.
    People have sent me all kinds of scripts and ideas but nothing has worked.

  2. #2
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rhonda
    I have an image randomizer and I need to put links on the images, how can I do that? This is the site where the randomizer is http://www.nenastran.com/testingsite/ and it is the large image on the left.
    People have sent me all kinds of scripts and ideas but nothing has worked.
    Well I don't know how your randomizer works, but it would be really simple to use a 2dim array, one cell being the image src and the other being the url. Then you can call both at the same time.
    Free Science Homework Help
    http://www.physicsforums.com

  3. #3
    SitePoint Member
    Join Date
    Nov 2003
    Location
    California
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi thanks for your reply, I am not too experienced with Javascript and I don't know what a "2dim array" is. This is the script I am using and I need the images to be linked to these pages
    industrial.jpg needs to link to studindustry.html
    aerospace.jpg needs to link to studaerospace.html
    automotive.jpg needs to link to studautomative.html
    marines.jpg needs to link to studmarine.html
    mechanical.jpg needs to link to studmechanical.html
    civil.jpg needs to link to studcivil.html
    Any help you could give me would be much appreciated

  4. #4
    SitePoint Member
    Join Date
    Nov 2003
    Location
    California
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops forgot the script....... <script language="JavaScript">


    function random_imglink(){
    var myimages=new Array()

    myimages[1]="aerospace.jpg"
    myimages[2]="automotive.jpg"
    myimages[3]="civil.jpg"
    myimages[4]="industrial.jpg"
    myimages[5]="marines.jpg"
    myimages[6]="mechanical.jpg"

    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<img src="'+myimages[ry]+'" border=0>')
    }
    random_imglink()

    </script>

  5. #5
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script language="JavaScript">
    
    
    function random_imglink(){
    var myimages=new Array()
    
    myimages[1]=["aerospace.jpg","http://www.url.com"]
    myimages[2]=["automotive.jpg","http://www.url.com"]
    myimages[3]=["civil.jpg","http://www.url.com"]
    myimages[4]=["industrial.jpg","http://www.url.com"]
    myimages[5]=["marines.jpg","http://www.url.com"]
    myimages[6]=["mechanical.jpg","http://www.url.com"]
    
    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<a href="'+myimages[ry][ry]+'"><img src="'+myimages[ry]+'" border=0></a>')
    }
    random_imglink()
    
    </script>
    Free Science Homework Help
    http://www.physicsforums.com


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
  •