ths code shows the photoes under preloadimages, but I cant add description out of it, can somebody pls help me where do I go wrong here? HTML: <html> <head> <script> function changeimage(towhat,url){ if (document.images){ document.images.targetimage.src=towhat.src gotolink=url } } function warp(){ window.location=gotolink if (type=="radio" && myForm.elements[0].checked){ document.write("test1"); } } </script> <! -- Automatic --> <script language="JavaScript1.1"> var myimages=new Array() var gotolink="#" function preloadimages(){ for (i=0;i<preloadimages.arguments.length;i++){ myimages[i]=new Image() myimages[i].src=preloadimages.arguments[i] myimages[i].value=document.write("descriptions.arguments[i]") } } preloadimages("img/img1.gif","img/img2.gif") </script> </head> <body> <p href="javascript:warp()"><img src="img/whale.gif" name="targetimage" width="500" height="190" border=0 ><br /><p>test</p></p> <div><input type="radio" title="Suiteliving1" name="suiteliving" value="1" CHECKED onClick="changeimage(myimages[0],this.href)"> a. Whaledive<img src="img/packages/image1.gif" width="285" height="150"/></div> </body> </html>
Code: function warp(){ window.location=gotolink if (type=="radio" && myForm.elements[0].checked){ document.write("test1"); } } Your trying to use a variable that is private to its original function. gotolink is not a global variable and is private to the functions its defined in. Also try using object notation this might help you better with your code. I won't write the code myself but I will give you advice. Create a function that has two params that are arrays. Each on will hold different info. One the images url, and the other the details.