swapping images (more than 1 instance)?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Cox

    #1

    swapping images (more than 1 instance)?

    Hello,

    Way back in 2000 Ken Cox put up this code for swapping images on a
    button.

    I cannot work out how to use it so that more than 1 button can use it.
    I guess the problem is knowing how to deal with the intImage value?

    Cheers

    Geoff

    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE=JavaSc ript>
    intImage = 2;
    function swapImage() {
    switch (intImage) {
    case 1:
    IMG1.src =
    "http://www.microsoft.c om/library/toolbar/images/mslogo.gif"
    intImage = 2
    return(false);
    case 2:
    IMG1.src =
    "http://msdn.microsoft. com/msdn-online/start/images/msdn-logo.gif"
    intImage = 1
    return(false);
    }
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <IMG id="IMG1" name="IMG1"
    src="http://www.microsoft.c om/library/toolbar/images/mslogo.gif"
    onclick="swapIm age();">
    </BODY>
    </HTML>
  • Randy Webb

    #2
    Re: swapping images (more than 1 instance)?

    Geoff Cox < said the following on 1/30/2008 4:17 AM:
    Hello,
    >
    Way back in 2000 Ken Cox put up this code for swapping images on a
    button.
    And he wrote an IE-only script.
    I cannot work out how to use it so that more than 1 button can use it.
    I guess the problem is knowing how to deal with the intImage value?
    Throw it away and start over.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Doug Gunnoe

      #3
      Re: swapping images (more than 1 instance)?

      On Jan 30, 10:48 am, Randy Webb <HikksNotAtH... @aol.comwrote:
      Be careful with that. The .src property of an image includes the full
      URL to the file. Not just the filename itself.
      Thanks. It's funny you should mention that. I did it that way because
      the url was a long string of goop and I was being lazy.

      Comment

      • Doug Gunnoe

        #4
        Re: swapping images (more than 1 instance)?

        On Jan 30, 2:59 pm, Geoff Cox <<>wrote:
        sorry Doug - stupid of me - I missed that for some reason.
        >
        Cheers
        >
        Geoff
        No problem. Good luck.


        Comment

        Working...