image+description problem

Discussion in 'Web Design, HTML And CSS' started by 2007160935, Oct 9, 2011.

  1. 2007160935

    2007160935 New Member

    Joined:
    Mar 6, 2009
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    ..
    Location:
    ..
    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)">&nbsp;a. Whaledive<img src="img/packages/image1.gif" width="285" height="150"/></div>
    
    </body>
    </html>
     
    Last edited by a moderator: Oct 10, 2011
  2. pein87

    pein87 Active Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    28
    Occupation:
    Web Dev
    Location:
    Limbo
    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.
     
    Last edited: Oct 10, 2011

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice