Buying Quick and Simple Javascript Rotation add to My .JS file

Discussion in 'Programming' started by grafx77, Sep 23, 2009.

  1. #1
    There is a variable within my .js file that is labeled:

    var url="http://mywebsite.com/control.php";
    Code (markup):
    and need a simple rotation within the javascript file so that it will go to numerous websites. Like this:

    var url="http://mywebsite.com/control.php";
    var2 url="http://mywebsite2.com/control.php";
    var3 url="http://mywebsite3.com/control.php";
    
    Code (markup):
    Immediate payment: $10
     
    grafx77, Sep 23, 2009 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 2
    #2
    Do you mean that it pick one by random?
     
    stephan2307, Sep 23, 2009 IP
  3. grafx77

    grafx77 Well-Known Member

    Messages:
    810
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    140
    As Seller:
    100% - 0
    As Buyer:
    100% - 4
    #3
    Yes.....that is correct
     
    grafx77, Sep 23, 2009 IP
  4. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 2
    #4
    ok this is the code

    
    var url = new Array;
    url[0] = "http://mywebsite.com/control.php";
    url[1] ="http://mywebsite2.com/control.php";
    url[2] ="http://mywebsite3.com/control.php";
    
    var randomnumber=Math.floor(Math.random()*url.length)
    
    
    Code (markup):
    then to use the url you simply use

    
    
    url[randomnumber]
    
    
    Code (markup):
     
    stephan2307, Sep 23, 2009 IP
  5. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 2
    #5
    if you want to add more urls just add another line but increment the number in the square brackets.
     
    stephan2307, Sep 23, 2009 IP
  6. grafx77

    grafx77 Well-Known Member

    Messages:
    810
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    140
    As Seller:
    100% - 0
    As Buyer:
    100% - 4
    #6
    Hmmm...thanks for the info, but for some reason, doesn't seem to work within my .js file.

    I am PMing you.
     
    grafx77, Sep 23, 2009 IP