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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can I make a page that randomly generates Amazon ads from a list?

    I've been working with this code which makes a button that randomly generates a quote. But if I simply insert the entire Amazon ad code inside the quotes it doesn't work. Any suggestions?
    Code:
    <div id="button">
    <a href="javascript:showNext()">Hit Me</a>
    </div>
    
    
    <div id = "theQuote"></div>
    
    <script type = "text/javascript">
    
    var quoteArray = [];
    
    quoteArray[0] = "blablabla" />";
    quoteArray[1] = "blablabla" />";
    quoteArray[2] = "blablabla" />";
    
    
    Array.prototype.shuffle = function() {  // unbiased shuffle
    var s = [];
    while (this.length) s.push(this.splice(Math.random() * this.length, 1));
    while (s.length) this.push(s.pop());
    return this;
    }
    
    quoteArray.shuffle();  // shuffle the array into a random order
    var count = 0;
    document.getElementById("theQuote").innerHTML = quoteArray[count];  // show first quote
    
    function showNext() {
    count ++;
    document.getElementById("theQuote").innerHTML = quoteArray[count];  // show the next quote
    if (count >= quoteArray.length-1) {
    quoteArray.shuffle();  // shuffle the array again
    count = -1;
    }
    }
    </script>

  • #2
    New Coder
    Join Date
    Jun 2014
    Posts
    23
    Thanks
    0
    Thanked 2 Times in 2 Posts
    you need to put your value in single quote like this quoteArray[0] = " 'blablabla' /> ";
    If your value is url then quoteArray[0] = "<a href='http://blahblahblah'></a> ";
    If your value is image then quoteArray[0] = "<img src='http://blahblahblah.jpg'/>";

  • #3
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What if it's this:

    Code:
    <a href="http://www.amazon.com/gp/product/B00HDOIB7A/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00HDOIB7A&linkCode=as2&tag=****lyrigene-20&linkId=7R2XTAEXHQE2Y5WN"><img border="0" src="http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00HDOIB7A&Format=_SL110_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=****lyrigene-20" ></a><img src="http://ir-na.amazon-adsystem.com/e/ir?t=****lyrigene-20&l=as2&o=1&a=B00HDOIB7A" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
    Just replace every " with a ' ?

  • #4
    New Coder
    Join Date
    Jun 2014
    Posts
    23
    Thanks
    0
    Thanked 2 Times in 2 Posts
    No then You just need to enclose the whole tag in single quote like this
    Code:
    '<a href="http://www.amazon.com/gp/product/B00HDOIB7A/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00HDOIB7A&linkCode=as2&tag=****lyrigene-20&linkId=7R2XTAEXHQE2Y5WN"><img border="0" src="http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00HDOIB7A&Format=_SL110_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=****lyrigene-20" ></a><img src="http://ir-na.amazon-adsystem.com/e/ir?t=****lyrigene-20&l=as2&o=1&a=B00HDOIB7A" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />'


  •  

    Posting Permissions

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