Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change a link's target based on a current image

    several weeks ago i asked a few questions and got a few answers regarding
    swapping more than 2 images back and forth in the same space.
    the solution was to use a function and put my 4 images in an array and have my left and right arrows just shiftleft and shiftright, calling the appropriate images. this worked great

    now im wondering if i can have a link elsewhere on my page point to multiple different
    pages or execute different actions, BASED on which image is currently on display.

    so say i have 4 images that i can loop thru using left and right arrows.
    i scroll thru them and leave it on image3 and then go click a button - and it plays a sound.
    then i swap the image again to image2, and click the same button, but this time it shows a layer that was hidden by default. swap again to say image4, and then click my button again and i go to a new page.

    is this possible?

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    878
    Thanks
    0
    Thanked 114 Times in 113 Posts
    Hello again indisi0us;

    if you use the script and page from the other thread (how can i... swapimage IF image = 'anyof4.gif' ??) then you can use this script:

    Code:
    function DoThat(){
    if (document.picture.src=Picture[0]){
    ..... do that ....
    }
    if (document.picture.src=Picture[1]){
    ..... do that ....
    }
    etc.
    }
    but if you want to refer directly to the image use this
    Code:
    function DoThat(){
    if (document.picture.src='MyMom.gif'){
    ..... do that ....
    }
    if (document.picture.src='MyDad.gif'){
    ..... do that ....
    }
    etc.
    }
    and then either
    Code:
    <input type="button" onClick="DoThat();" value="Click Here">
    or
    Code:
    <a href="javascript:DoThat()">Click here</a>


  •  

    Posting Permissions

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