Java / DHTML question

I am looking to display text on an HTML page which changes every x seconds. For example, a sentence might read: "Last minute offers on the following: Florida, Jamaica, Greece". I would like the named places to change in order from Florida, then Jamaica and then Greece etc.

Any ideas how I go about doing this? I assume the code references an array of text to be displayed at different time intervals.

Can anyone supply me with the code to do this please? I've not done much java or dhtml before - go easy with me!

Thanks for your help.
Who is Participating?
bri53Connect With a Mentor Commented:

Go to

There you will find links to free java applets that you can download. Sun has one that allows you to edit it with your own text messages as well as the delay. Is this what you are looking for?
Hmm, bunch of ways to implement this.

compatibility vs. look

for compatibility, you need to put the "dynamic" text inside a textbox / textarea and use setTimeout javascript function to switch between the messages.

sample code:

var arrText = new Array("Last minute offers on the following:","Florida","Jamaica","Greece");
var lngIndex = 0;

function switchText() {
  document.frmSomething.txtFlasher.value = arrText[lngIndex]

lngIndex = (lngIndex+1 < arrText.length) ? lngIndex++:0;

//call this function back every 5 seconds.

or a separate frame that use META REFRESH / javascript to update the frame w/ different HTML source every so often.

for look you can experiment w/ DHTML for 4.0 browsers which I won't go into, you can look up a lot of reusable DHTML components such as this (also step by step instruction) on
You could also think about setting up an animated gif.
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

or flash...
ombAuthor Commented:
PBall - thanks for your javascript. Unfortunately, I can't seem to get it to work. I am new to coding & not really quite sure where to put the sample you've given me. Please could you please give me a sample of the html you embed this javascript in. Basically a plain text page with a line of text and then the 'dynamic' text changing.

Currently I use an animated gif - that's fine but a real pain when I need to change the text & have to re-optimised. Flash would be fine too, but surfers require a plug-in & I don't want to narrow my audience down to just see some animated text.

Thanks so much for all your useful comments.
ombAuthor Commented:
PBall - sorry, but I still can't get this to work... are you able to help me any further?

ombAuthor Commented:
Anyone able to offer me further help on this javascript?

All Courses

From novice to tech pro — start learning today.