hi, on my page i'd like my topbanners to load random on each page. I mean that if i open index, banner1 loads and when I press "Update" maybe banner3 loads.
Do any of you know the code for that?
Try searching Hotscripts for Banner Rotation scripts. I have seen them done with PHP, Java, and other server sided languages but not with Javascript, although I believe it should be possible.
If Hotscripts doesn't have what your looking for, try using Google.
P.S. I don't know what kind of web hosting you have but I just noticed that CPanel (Linux/Unix online webhosting control panel) has a built in script called Entropy Banner that may be something like what you are looking for.
I have a JavaScript banner rotator on my site that uses a .js file to store the details of each banner, and then a function to select a random banner. The essential basics of the function are shown below:
Code:
function banner() {
which = Math.random();
which = Math.round(which*howmany);
document.images['banner'].src = urls[which];
}
The variable howmany is stored in the .js file with the url information and is simply a howmany = urls.length-1; statement (the array that the urls are stored it is called urls).