Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Unhappy Variable to be used in href

    Please check out the code and tell me how can i use the variable as a href link.

    var rand_link = new Array ();
    rand_link[0]="asdhrfe22k";
    rand_link[1]="iqh3wjhs8s";
    rand_link[2]="snbds7s8h3";
    rand_link[3]="=jh99shhs99";
    rand_link[4]="shdbfh3h83";

    var rand = Math.floor(5 * Math.random());

    var ref = rand_link[rand];

    document.write("<a href=http://www.youtube.com/watch?v= [with the variabel "ref"]>Click here</a>");

    where, the array of links are in rand_link.

  • #2
    New Coder
    Join Date
    Jun 2010
    Location
    The Netherlands
    Posts
    53
    Thanks
    0
    Thanked 6 Times in 6 Posts
    doucment.write("<a href='http://youtube.com/"+ ref +"'>Click here!</a>");

  • Users who have thanked Candan for this post:

    geekyvirgin (07-14-2010)

  • #3
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Candan, thank you for your help .. It worked


  •  

    Posting Permissions

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