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))]); Link to comment https://forums.phpfreaks.com/topic/170501-solved-change-text-every-60-seconds/ 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))]; Link to comment https://forums.phpfreaks.com/topic/170501-solved-change-text-every-60-seconds/#findComment-899403 Share on other sites More sharing options...
lynxus Posted August 16, 2009 Author Share Posted August 16, 2009 Thanks works great. -G Link to comment https://forums.phpfreaks.com/topic/170501-solved-change-text-every-60-seconds/#findComment-899422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.