[thelist] images as radio buttons

Benjer futureweb at macmail.com
Wed Oct 16 10:49:01 CDT 2002


this should help:

function flip(who,imageSwap) {
        if (isNS4) {
            document.images[who].src = imageSwap;
        }
        if(isIE4){
            document.images[who].src = imageSwap;
        }
        if(isDOM){
            document.getElementById(who).setAttribute('src', imageSwap);
        }
}
var next="";
var chosen="default on image name here";
function changeRadio(next){
    returnImage='../images/'+chosen+'.gif';
    flip(chosen, returnImage);
    chosen=next;
    replaceImage='../images/'+chosen+'on.gif'
    flip(chosen, replaceImage);
}

onClick="changeRadio('char1A')

Benjer


On 16/10/02 5:28 pm, "Michael Robertson" <mike at mikeemedia.com> wrote:

> --
> [ Picked text/plain from multipart/alternative ]
> I'm trying write a javascript function that will allow me to select an image
> from a  group of images like radio buttons and change when selected as well as
> have the corresponding radio button checked when the image is clicked. This is
> kind of working however sometimes the images just disappears when clicked as
> opposed to changing and I would also like the image to return to it's original
> state when another image is checked. Any suggestions to accomplish this.
>
> function pickChar(who,what,on){
> if(!document.getElementById(who).checked){
>  document.getElementById(who).checked=true;
>  document.getElementById(what).src= on;
>  }
> }
>
> <div id="charLayer1">
>       <div class="txtcenter">
>           <a href="javascript:;"
> onClick="pickChar('char1','dude1','../images/char1Aon.gif')">
>               <img src="../images/char1A.gif" width="73" height="103"
> name="dude1" id="dude1" border="0" />
>               </a><br />
>               <input name="Character" type="radio" value="char1" id="char1" <%
> If charMod="char1" Then%> checked <% End If %> />
>       </div>
>   </div>
> --
>





More information about the thelist mailing list