PDA

View Full Version : random banner image change on page load each time



sujata_ghosh
06-26-2008, 11:59 AM
hi to all!

i am looking for some JS script using this i can change banners everytime i load one page. every time i load the page the banner image will get change automatically.

can anyone help me on this script? its very urgent.


Thanks in advance.

Nile
06-26-2008, 01:58 PM
Ok, you want to put this in the <head> section of your code.
Blue: The number of your headers -1
Magenta: The id of your header(or the banner's id).
Green: The image with the <img> tag.
You can add more if statements depending on your images.

<script type="text/javascript">
// Generate a Random Number
var movieDis; //global variable
var number = 2; //your number of videos -1
var randomnumber = Math.round(Math.random()*number+1); //generate a random number between 1-number+1
movie(randomnumber, 'div');

//Functions to write out the correct flash movie resource.
function movie(num, el){
if(num == 1){
movieDis = "image1";
} else if(num == 2){
movieDis = "image2";
}else if(num == 3){
movieDis = "image3";
} else {
movieDis = "There was an error. Please try again."; //error
}
document.getElementById(el).innerHTML=movieDis;
}
</script>

sujata_ghosh
06-30-2008, 07:37 AM
thanks for your reply!

but it not working, as i think this code is incomplete. can u recheck and get back to me, there is nothing for body section, without that how can a page display image?