Javascript help please!!

Discussion in 'After Hours Lounge (Off Topic)' started by Ross Williams, May 29, 2003.

  1. Ross Williams

    Ross Williams Supporting Actor

    Joined:
    Feb 9, 1999
    Messages:
    653
    Likes Received:
    0
    Trophy Points:
    0
    I'm dying here. I've been working at this for a few hours now to figure this out. Seems simple enough. I was working from: http://htmlgoodies.earthweb.com/tutors/imageflip.html - I can figure out how to flip one image no problem. As soon as I add a 2nd image, only that 2nd image will flip, the first won't budge. Following the directions here, it seems simple, but I just can't get it to work. I've looked at 20 different other html help sites, they all seem to have different instructions.

    The page I'm trying to make this work on is here: http://64.68.191.56/~thechris/menu.html

    Take a look at my source and tell me what's wrong. I'll be forever grateful!
     
  2. David Crawford

    David Crawford Auditioning

    Joined:
    Jun 30, 1997
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    hey there,

    i don't really know any javascript, but from a quick look at the code, surely you need 3 pairs of swap functions, and each with unique names.

    i guess it's a quirk of javascript interpretation that allows you to have 3 identically named swapout functions, but you are only ever executing the last pair.

    try making swapout1 and swapback1 for image1, swapout2 swapback2 for image2 etc etc.

    hook up the appropriate function pairs to the href events and i guess you should be cooking

    let us know what happens

    David
     
  3. David Crawford

    David Crawford Auditioning

    Joined:
    Jun 30, 1997
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    oh, one more thing. I had another look, and you've got the same problem with the global object image1 and and image2.

    as above these will need to be sepearted from each, probably call the first pair something image1_1 and and image1_2 so that swapout1 can flip the correct images for you

    probably starting to get a bit clunky, can't you use a 2 dimensional array of image objects, and then pass a parameter in the event function to tell a generic pair of swap functions what images to flip.

    like i say, i don't actually know any javascript, but the changes described should get you a bit closer to where ou need to be.
     
  4. Andy_MT

    Andy_MT Second Unit

    Joined:
    Jun 23, 2001
    Messages:
    486
    Likes Received:
    0
    Trophy Points:
    0
    Ross,

    have a look at this site : http://www.dynamicdrive.com/dynamicindex15/domroll.htm

    this does what you're looking for. as the saying goes, if at first you don't succeed, copy someone else.

    had a look through your code. you're over complicating things; you don't need such an elaborate solution. i can see why it's not working, but i think the code would need to be completely re-written and it would take too long to go into specifics. i think that link should help you out though.
     
  5. Ross Williams

    Ross Williams Supporting Actor

    Joined:
    Feb 9, 1999
    Messages:
    653
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for your help guys. Andy, I'll try that code, see if I can get it to work that way.

    5 minutes later... Andy your a lifesaver! Worked like a charm.
     

Share This Page