View Full Version : Errors.
Alucard
02-14-2003, 05:45 PM
Does anyoen see the error in this code? I'm trying to swap images.
<script language="JavaScript">
<!--
function imgswap(s){
var bt="/images/pets/happy/";
t1.elements.src=bt+document.pets.imgname.value+".gif";
}
function imgreplace(s){
var bt="/images/pets/";
t1.elements.src=bt+document.pets.imgname.value+".gif";
}
//-->
</script>
joh6nn
02-14-2003, 06:13 PM
t1.elements isn't an image, so you can't assign an image to it's source. t1 isn't defined anywhere in the code you posted. based on the fact that you're calling the elements property, i'd say it's supposed to be a form. but the .elements property is supposed to be an array of all the items in the form. so, based on that, i'm guessing that you're trying to change the images of <input type="image"> button. if that's what you're trying to do, then try the following:
<script language="JavaScript">
<!--
function imgswap(){
var bt="/images/pets/happy/";
document.t1.INPUTNAME.src=bt+document.pets.imgname.value+".gif";
}
function imgreplace(){
var bt="/images/pets/";
document.t1.INPUTNAME.src=bt+document.pets.imgname.value+".gif";
}
//-->
</script>
also, i noticed that in the script you posted, you passed arguments to the functions, that never get used. why was that?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.