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.
LVL 3
ombAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PBallCommented:
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.
setTimeout("switchText()",5000);
}

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 www.webreference.com/dhtml
0
mayhewCommented:
You could also think about setting up an animated gif.
0
mflamCommented:
or flash...
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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.
0
ombAuthor Commented:
PBall - sorry, but I still can't get this to work... are you able to help me any further?

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

Thanks
0
bri53Commented:
omb:

Go to http://java.sun.com

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?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.