• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Different image reload in the page when i click in the refresh(f5)

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Different image reload in the page when i click in the refresh(f5) and also images will come in sequence... like img1 ,img2, img3... but not randomly...

Please give me the solution. it very Essential for me.

thank you.

Soumen
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you would need to store a cookie value with what index the person is on. When the page loads you read the cookie and you set the source of the image with a value from an array.

Eric
 
s paul
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the code. please have a look.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Change Images</title>
</head>

<body>
<script language="JavaScript">
<!--
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
//alert("VAL: " + ad);
if (ad==1) {
alt="PRIME definition"; banner="images/image1.jpg";
width="750";
height="500";
}
if (ad==2) {
alt="PRIME definition"; banner="images/image2.jpg";
width="750";
height="500";
}
if (ad==3) {
alt="PRIME definition"; banner="images/image3.jpg";
width="750"; height="500";
}
document.write('<center>');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('</center>');
// -->
</script>
</body>
</html>


images should be come in sequence...like img1 ,img2, img3....... img1, img2. img3... for every refresh ... but not randomly... and work in all browser...

Please help me.

thanking you

soumen
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you post code here, please use code tags.

As I said before, you need to use a cookie to store the last value. When your code first loads you check the cookie and see if there is a value, if there is use it.

Eric
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic