...

View Full Version : changing image



jay_66
02-26-2003, 04:56 AM
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>

vickers_bits
02-26-2003, 05:40 AM
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


<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum