What's wrong with this code??

Discussion in 'JavaScript' started by Lexxi, Apr 25, 2007.

  1. #1
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>

    <body>

    <script language="JavaScript" type="text/javascript">

    var wishlistCookie = "";

    if(document.cookie && document.cookie != ""){
    process_cookie()

    function process_cookie(){
    var whole_cookie = unescape(document.cookie);
    var each_cookie = whole_cookie.split(";");

    for (i=0; i < each_cookie.length; i++){

    if (each_cookie.indexOf("wishlist") > -1){wishlistCookie = each_cookie}

    }
    }
    }
    </script>


    <script>

    if (document.cookie != ""){
    wishlist = document.cookie
    }

    var A= unescape(wishlistCookie).split(/ *& */);
    var L=A.length, tem,temp;

    var panArray=[];
    for(var i=0;i<L;i++){
    tem=A.split(/ *\: */);
    temp=tem[1].split(/ *\= */);
    panArray.push(['<img src="images/' + tem[0] + '.jpg" alt="' + temp[0] + '">' + '<h3>' + temp[0] + '</h3><p><a href="' + temp[1] + '.htm"> Product Page</a><hr>'])
    }

    document.write(panArray[0] + '<br/>' + panArray[1]+ '<br/>' + panArray[2]+ '<br/>' + panArray[3])



    </script>

    </body>
    </html>


    It wont show in firefox, and in all the others, the first image wont show up.

    Help??
     
    Lexxi, Apr 25, 2007 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Without seeing the expected format of the cookie, it's difficult to confirm that it's being parsed properly.
    Have you tried alerting panArray to confirm that it contains what you expect?
     
    Logic Ali, Apr 26, 2007 IP
  3. Dude111

    Dude111 Guest

    Messages:
    1,153
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have tried it as an HTM and a PHP file and i see nothing in IE when i launch it.... (Im using MyIE2 in front of IE)
     
    Dude111, May 1, 2007 IP