lynxus Posted August 16, 2009 Share Posted August 16, 2009 Hi guys, Ive got a script on my page that when a user loads the page it places a random tip of the day. My question is: How can i get this to just update every 60 seconds? I sould assume it would be something needed to call the javascript every 60 seconds. and then something like document.totd.value = totd.js ? Or something like that? Could someone help please. Im crap with javascript lol. Thanks Graham <div id="totd"><script src="totd.js" type="text/javascript"></script></div> // JavaScript Document var quotes = new Array; quotes.push("Click Go Online to start recieving messages from your users."); quotes.push("Click My Website Code to see any new buttons for your site."); quotes.push("Keep missing chat requests? Try the SMS / TXT message alert option."); quotes.push("Add your Status Icon to more that one page on your site to increase your chances of a support request."); quotes.push("Responding to your visitors chat requests fast will increase your chances of a sale."); quotes.push("Click Go Online to start recieving messages from your users"); document.write(quotes[(Math.floor(Math.random() * quotes.length))]); Quote Link to comment Share on other sites More sharing options...
smerny Posted August 16, 2009 Share Posted August 16, 2009 "document.totd.value = totd.js" is your phrase inside any tags? value would work if you had it within a text input or something... otherwise you could put it inside of a div, with an id (like totd): <div id="totd">This is a tip</div> which would allow you to use innerHTML: document.getElementById('totd').innerHTML = quotes[(Math.floor(Math.random() * quotes.length))]; Quote Link to comment Share on other sites More sharing options...
lynxus Posted August 16, 2009 Author Share Posted August 16, 2009 Thanks works great. -G 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.