PDA

View Full Version : want to update a banner dynamically


steveclondon
11-09-2005, 02:47 PM
Hi

I am new to Javascript although I have been programming PHP for some time.

I want to update a banner dynamically. I have some arrays with the urls title and how many seconds i want the banner to display.

I am then going to loop through the array and want the banner to update each time with the new banner.

Im not worried about the looping section array section however I want to know how to make the page reload the banner in a set time?

Pyth007
11-09-2005, 03:49 PM
You'll want to use either setTimeout() or setInterval() methods....
For example:
<html><head>
<script type="text/javascript">
var myNumber=0;
function myFunction()
{
++myNumber;
document.getElementById('myTextBox').value=myNumber;
}
</script>
</head>
<body onLoad="setInterval('myFunction()',1000)">
Timer:
<input type='text' id='myTextBox' readonly style="width:100">
</body></html>

setTimer / setInterval takes two args: the function / expression you want to run inside quotes and the number of milliseconds to pause before running said function. The difference between the two functions is that Timer runs the arg-function once after the delay whereas Interval continually runs the arg-function pausing for the delay time in between each.