Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: changing image

  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    changing image

    i wanna have a specific spot on the screen designated for a players profile which will just be a .jpg file, and which will change to the player they have selected in the drop down list when the user clicks the button. for some reason this code will not work, if someone could give me a hand, it would be greatly appreciated.


    <input type="button" name="test" value="Click Here To View Selected Player's Profile" onclick="profile()">
    </form>

    <img src="standard.jpg" height = "300" width="300" name="stand" />

    <script language="javascript">

    1.src="1.jpg"


    function profile()
    {
    var img=document.selection.choice.options[document.selection.choice.selectedIndex].value

    return
    document.images.stand.src=eval(img+".src")

    }
    </script>

  • #2
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    variable names can't begin with a number (1.src="1.jpg")
    best to preload the images before you call upon them
    you might also need to add an id attribute to the img tag. use it's name

    Code:
    <script type="text/javascript" language="javascript"><!--
    imgFolder="..//graphics//";
    imgs=new Array();
    imgs[1]=new Image();
    imgs[1].src=imgFolder+"1.jpg";
    imgs[2]=new Image();
    imgs[2].src=imgFolder+"2.jpg";
    
    function profile(){
     if (document.images)
      document.images["stand"].src=imgs[document.selection.choice.value].src;
    };
    //--></script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •