471,852 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

dynamic text using settimeout

Hi,

I am trying to create a header on a page that switches between 7 textitems
in an array.
using this code:

<script language="JavaScript">
season=new Array("summer","winter","fall","spring",")
i=0
function raise()
{
setTimeout('i=i+1',2000);
if(i>4){i=0}
}
</script>

</head>

<body onLoad="raise()">
<script language="JavaScript">

document.write(season[i]);
</script>

can anybody please explain me why this doesnot work.

greets,

Sybolt

Jul 23 '05 #1
2 1369

"S.Hoitinga" <s.********@chello.nl> wrote in message
news:oC*****************@amsnews03.chello.com...
Hi,

I am trying to create a header on a page that switches between 7 textitems
in an array.
using this code:

<script language="JavaScript">
season=new Array("summer","winter","fall","spring",")
i=0
function raise()
{
setTimeout('i=i+1',2000);
look at setInterval, setTimeout only runs once. It still won't work the way
I think you want it to because the document.write only executes when the
page is rendered.

Also, the variables in the setTimeout shouldn't be quoted

Start over... Post it up.

Look at: innerHTML and % (modulo arithmetic)

Jeff

if(i>4){i=0}
}
</script>

</head>

<body onLoad="raise()">
<script language="JavaScript">

document.write(season[i]);
</script>

can anybody please explain me why this doesnot work.

greets,

Sybolt

Jul 23 '05 #2
You asked that same question 6 days ago, with a lot of reply. It should
help you enough to get it working.

S.Hoitinga wrote:
Hi,

I am trying to create a header on a page that switches between 7 textitems
in an array.
using this code:

<script language="JavaScript">
season=new Array("summer","winter","fall","spring",")
i=0
function raise()
{
setTimeout('i=i+1',2000);
if(i>4){i=0}
}
</script>

</head>

<body onLoad="raise()">
<script language="JavaScript">

document.write(season[i]);
</script>

can anybody please explain me why this doesnot work.

greets,

Sybolt


Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Cybex | last post: by
2 posts views Thread by Randell D. | last post: by
8 posts views Thread by S.Hoitinga | last post: by
6 posts views Thread by Vanitha | last post: by
NeoPa
reply views Thread by NeoPa | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.