Change between two images ?

Discussion in 'Javascript' started by Jürgen Heyn, Feb 13, 2004.

  1. Jürgen Heyn

    Jürgen Heyn Guest

    Good evening,

    I have problems to change between two images.
    My project consits of 3 frames (Index.htm, Frame1.htm and Frame2.htm). In
    the Index.htm I declared:

    var PartNo = new Array();

    var Checked = new Image();
    Checked.src = "../Buttons/Checked.gif"; // Image1
    var UnChecked = new Image();
    Unchecked.src = "../Buttons/Blank16.gif"; // Image2

    In Frame1.htm I have several forms. In form[0] I embedded an image. This
    index of the image in the document is[1].
    A graphical Button should switch from Image1 to Image2
    <img src="../Buttons/Blank16.gif" border="0" width="16" height="16">
    <input src="../Buttons/Button.bmp"
    onClick=RefreshItems(this.form.elements[1].value) border="0" width="36"
    height="36" type="image">

    Unfortunately the following code does not work... ;( and I have no idea
    what I did wrong.
    I would greatly appreciate any hint. Thank you very much in advance.

    Best regards
    Juergen Heyn, Wilhelmshaven, Germany

    <script language="JavaScript">
    <!-- Beginn

    function RefreshParts(pPartNo)
    {
    for(var i = 1; i <= document.forms.length; i++)
    for(var j = 0; j <= parent.PartNo.length; i++)
    if(parent.PartNo[j] == pPartNo)
    {
    SwitchImage(true);
    break;
    }
    }

    function SwitchImage(checked)
    {
    if(checked)
    document.images[1].src=parent.Checked.src;
    else
    document.images[1].src=parent.Unchecked.src;
    }

    // End -->
    </script>
    Jürgen Heyn, Feb 13, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    894
    Eliyahu Goldin
    Jan 4, 2005
  2. GenxLogic
    Replies:
    3
    Views:
    1,268
    andrewmcdonagh
    Dec 6, 2006
  3. Kevin D. Smith
    Replies:
    4
    Views:
    668
    Kevin D. Smith
    Oct 27, 2008
  4. hrm
    Replies:
    4
    Views:
    203
  5. vj
    Replies:
    3
    Views:
    239
Loading...

Share This Page