www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] URL variables ???

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Posts
    9

    resolved [RESOLVED] URL variables ???

    I'm trying to retrieve a url variable can anyone help me?


    <script type="text/javascript">


    var x = [];

    x[1] = ["9.99","african_kente_buy.php"];
    x[2] = ["9.99","african_love.php"];
    x[3] = ["9.99","too.php"];
    x[4] = ["14.99","jon_f.php"];
    x[5] = ["14.99","jon_fab.php"];
    x[6] = ["9.99","ceo.php"];
    x[7] = ["9.99","click.php"];
    x[8] = ["9.99","jesus.php"];
    x[9] = ["14.99","fabio.php"];
    x[10] = ["9.99","live.php"];

    var rands = uniqueRandomArray(10,1);

    for(i=0;i<3;i++){
    document.write("<div class='sug'><a href='"+x[rand[i]][1]+"'><img border='0' style='position:absolute; padding-bottom:3px; clip:rect(0px,80px,80px,0px)' src='sug_img/Picture_"+rands[i]+".png'></a><div style='position:absolute;top:80px;width:95%;text-align:right'>"+x[rand[i]][0]+"</div></div>");
    }

    </script>

  2. #2
    Join Date
    Aug 2009
    Posts
    593
    I don't have your uniqueRandomArray function to test properly but...

    You are using a rand variable in your document.write when you have only declared a rands variable.

    Code:
    document.write("<div class='sug'><a href='"+x[rand[i]][1]+"'><img border='0' style='position:absolute; padding-bottom:3px; clip:rect(0px,80px,80px,0px)' src='sug_img/Picture_"+rands[i]+".png'></a><div style='position:absolute;top:80px;width:95&#37;;text-align:right'>"+x[rand[i]][0]+"</div></div>");

  3. #3
    Join Date
    Oct 2009
    Posts
    9

    Smile calling URL variables

    Yeah I think that may have been the problem, however I decided to use the window.open method instead plus I made my urls absolute instead of relative. I'm going to take out the styling for the finished site but here's the working code: Thanks

    Code:
    function uniqueRandomArray(limit,ex){
    var i, j, q, rn, ar=[];
    
    for(i=0;i<3;i++){
    q=false
    rn=Math.ceil(Math.random()*limit);
    	for(j=0;j<ar.length;j++){
    	if(rn==ar[j]){q=true;break}
    	}
    
    rn==ex||q?i--:ar[ar.length]=rn;
    }
    return ar;
    }
    var x = [];
    
    x[1] = ["9.99","http://www.fkprint.com/african_kente_buy.php"];
    x[2] = ["9.99","http://www.fkprint.com/african_love.php"];
    x[3] = ["9.99","http://www.fkprint.com/too.php"];
    x[4] = ["14.99","http://www.fkprint.com/jon_f.php"];
    x[5] = ["14.99","http://www.fkprint.com/jon_fab.php"];
    x[6] = ["9.99","http://www.fkprint.com/ceo.php"];
    x[7] = ["9.99","http://www.fkprint.com/click.php"];
    x[8] = ["9.99","http://www.fkprint.com/jesus.php"];
    x[9] = ["14.99","http://www.fkprint.com/fabio.php"];
    x[10] = ["9.99","http://www.fkprint.com/live.php"];
    
    var rands = uniqueRandomArray(10,1);
    
    for(i=0;i<3;i++)
    {
    document.write("<div class='sug'><img onclick='sugPage(rands["+i+"])' border='0' style='position:absolute; padding-bottom:3px; clip:rect(0px,80px,80px,0px)' src='sug_img/Picture_"+rands[i]+".png'><div style='position:absolute;top:80px;width:95%;text-align:right'>"+x[rands[i]][0]+"</div></div>");
    function sugPage(z){
    	window.open( x[z][1] ,"_top");
    }
    
    }

  4. #4
    Join Date
    Oct 2007
    Location
    Western Massachusetts, USA
    Posts
    387
    Remember to encode &#163; as an HTML entity.
    Computer programmer / web developer.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles