houstonrockets16 Posted April 18, 2012 Share Posted April 18, 2012 Hi there,I need some help. I am trying to place random customer testimonials (using the random quote generator) on my right bar on the home page, and I would like that customers picture to show up underneath the random testimonial.Basically, if the random number is "1" then quote 1 and picture 1 need to show up.I got the quote part to work, but anytime I put any img tag in the code, nothing shows up or works. Could someone please help? My website is www.thegreatcanvas.com and my code so far is below! I knwo that I have the same random quote message right now... please help I couldn't find anything similar in the forums or on google!I will give whoever helps me a giftcard to my store <script>var num_of_quotes = 3;quotes = Math.floor (num_of_quotes * Math.random());if (quotes==0) {myRanQuote="My Dali painting turned out beautiful. It has really made my home look more hip! Thank you! <BR> Chris, TX";}if (quotes==1) {myRanQuote="My Dali painting turned out beautiful. It has really made my home look more hip! Thank you! <BR> Chris, TX";}if (quotes==2) {myRanQuote="My Dali painting turned out beautiful. It has really made my home look more hip! Thank you! <BR> Chris, TX";}document.write(myRanQuote);</script> Link to comment Share on other sites More sharing options...
Ingolme Posted April 18, 2012 Share Posted April 18, 2012 Arrays would make it easier. All you have to do is use the generated random number on two different sets of data: var quote = [];quote[0] = "Quote 1";quote[1] = "Quote 2";quote[2] = "Quote 3"; var image = [];image[0] = "file1.jpg";image[1] = "file2.jpg";image[2] = "file3.jpg"; var n = Math.floor(quote.length * Math.random()); document.write("<img src='" + image[n] + "' alt='[image]'>" + quote[n]); 1 Link to comment Share on other sites More sharing options...
houstonrockets16 Posted April 18, 2012 Author Share Posted April 18, 2012 wow, i am going to try this, thanks so much i will let you know if it works Link to comment Share on other sites More sharing options...
houstonrockets16 Posted April 18, 2012 Author Share Posted April 18, 2012 i think this is going to work, i will let you know if i have any other questions... also, please tell me how i can send you a gift card for helping Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now