dennismonsewicz Posted July 2, 2008 Share Posted July 2, 2008 I have done some minor javascript but nothing really major. I have used jQuery for a lot of stuff I have done (I know, I know its cheating, please don't hate me for it), but I need help with writing a function that will display a group of images at random with text that corresponds to the image and the images cannot repeat. LOL any help at all is grealy appreciated! Thanks! Quote Link to comment Share on other sites More sharing options...
adam84 Posted July 8, 2008 Share Posted July 8, 2008 This may not be the greatest approach, but it should work. Load you images and your text into a javascript array. ie imgs[0][0] = 'me.jpg'; imgs[0][1] = 'Me at the park'; imgs[1][0] = 'you.jpg'; imgs[1][1] = 'You at the park; Then create a timeout function to call every x secs In the function the you call every x secs, you can use a counter to the next image that should be displayed, or you can randomly select an image. Once you have your selected image/comment, you can change the SRC of your IMG tag (document.getElementById('img').src= imgs[x][0]; ) and change the text of your DIV/SPAN (document.getElementById('imgTxt').innerHTML= imgs[x][1]; ) text for the comment. 'x' equals the picture you want to display. Hope this helps. Probably not.. hahaha Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.