Swap image with check/uncheck of Radio Button

Discussion in 'Javascript' started by lemat@attglobal.net, Jan 8, 2007.

  1. Guest

    Hi,
    I use a radio button form in which users can select a color by clicking
    on a image.
    I would like this image to change to another one when it's chosen.
    (image with a "Chosen" Stamp in the middle)
    Of course I like it to be restored if hte user select another color.

    I've tried to add behaviour to the image (swap on click) and on the
    button (onchange swap restore) but it doesn't work (hte image id
    swapped and restored almost instantly).

    Any ideas ?

    Mathieu
    , Jan 8, 2007
    #1
    1. Advertising

  2. Guest


    > >

    > <input ... onclick=
    > 'if(this.checked)document.images["imageName"].src="chosen.img"'>
    > <input ... onclick=
    > 'if(this.checked)document.images["originalImageName"].src="original.img"'>
    >
    >
    > Mick


    Thank you Mick,

    I have 10 radio buttons, i can paste copy ten times the code and be
    careful or do a function:
    onclick="changeimages("ImageName1")"
    but how do transalte document.images["imageName"].src="chosen.img"' if
    i use a java script function.
    document.form['myRadioGroup
    Name'].images["imageName"].src="chosen.img"' , it dosen't work.

    I want to do a loop on every buttons with the image having a
    Nameimage+i name.

    mat
    , Jan 9, 2007
    #2
    1. Advertising

  3. Guest

    i did it !!!

    function change(idgroupimage)
    {
    for(var i=1;i<3;i++)
    {
    if (i!=idgroupimage)
    {
    eval
    ('document.form1.nameimage'+i+'.src="Photos/GIF/nameimage'+i+'.gif"');
    }
    else eval
    ('document.form1.nameimage'+i+'.src="Photos/GIF/nameimage'+i+'_ok.gif"');
    }
    }
    , Jan 9, 2007
    #3
    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. Replies:
    0
    Views:
    653
  2. Niels Dekker (no reply address)

    What swap is called when using std::swap?

    Niels Dekker (no reply address), Jul 19, 2006, in forum: C++
    Replies:
    4
    Views:
    970
    Niels Dekker (no reply address)
    Jul 20, 2006
  3. Hiten
    Replies:
    1
    Views:
    594
    Vidar Petursson
    May 26, 2004
  4. Ken Loomis

    Checked radio button doesn't uncheck

    Ken Loomis, Dec 31, 2003, in forum: Javascript
    Replies:
    1
    Views:
    220
    Ken Loomis
    Dec 31, 2003
  5. cerr

    uncheck radio group

    cerr, Nov 5, 2011, in forum: Javascript
    Replies:
    7
    Views:
    1,196
    Dr J R Stockton
    Nov 6, 2011
Loading...

Share This Page