Rotating pictures

S

Sehboo

Hi,


I am looking for code which can rotate pictures without refreshing the
page. I want to read randomly selected 5 images from
database and then keep on rotating them every 5 seconds.


Any help is appreciated.
 
E

Evertjan.

Sehboo wrote on 13 okt 2005 in microsoft.public.inetserver.asp.general:
I am looking for code which can rotate pictures without refreshing the
page. I want to read randomly selected 5 images from
database and then keep on rotating them every 5 seconds.


And you want to do this serverside?
Only the random selection can be done serverside.
For the "rotation" I would suggest you go to a clientside NG.

And then, did you have some code in mind,
or do you want someone to do all the work?
 
S

Sehboo

Hi,

I have the javascript code which does the slideshow, but I want to read
the image URLs from database, and not hard code them here. Here is
what I have so far.

var timerID=0;

var imgArray = new Array("images\116.gif", "images\117.gif",
"images\118.gif", "images\119.gif");
// I want to read the above array from database.

function setupAdbanner() {
rotateBanner();
timerID = setInterval("rotateBanner()", 5000);
}

function cleanupPage() {
if (timerID)
clearInterval(timerID);
}

function rotateBanner() {
imgIndex = Math.ceil(Math.random() * imgArray.length) - 1;
document.images["HatContestPhotos"].src= imgArray[imgIndex];
}
 
E

Evertjan.

Sehboo wrote on 13 okt 2005 in microsoft.public.inetserver.asp.general:
var imgArray = new Array("images\116.gif", "images\117.gif",
"images\118.gif", "images\119.gif");
// I want to read the above array from database.

Now we are getting somewhere.
[please always quote the text you are responding on,
this is usenet, not email]

Next question is, what database you have?
..mdb-file, .txt-file, etc.
 
S

Sehboo

I have SQL Server.

(I don't know how to include the original text - It is not giving me
the option to include it)
 
A

Andrew

you have to load all the images to the client's browser and minimize them
first, then your script can call them as you want.
If the client's browser doen't request anything when it is static, it can't
display the images from your server?

<img src="images/0.gif" width="1" height="1">
<img src="images/1.gif" width="1" height="1">
<img src="images/2.gif" width="1" height="1">
<img src="images/3.gif" width="1" height="1">
<img src="images/4.gif" width="1" height="1">
 
S

Sehboo

I don't know if this will work. How can I call asp function from
javascript? If that is possible then I can just call database from my
asp function.
 
E

Evertjan.

Sehboo wrote on 13 okt 2005 in microsoft.public.inetserver.asp.general:
I don't know if this will work.

What will work? If you don't show us where you are answering on, how
should we know where you are talking about?
How can I call asp function from
javascript? If that is possible then I can just call database from my
asp function.

No that is impossible, as serverside asp executes first and sends the
result as a html-file tot he client.

=========

I am not versed in SQL server, but with the jet-engine [MS-access]
I would do something like this:


=======================================================
<%
[open the database]

SQL = "select imgName from imgTable"
mD = CONNECT.Execute(SQL)

response.write "<script type= 'text/javascript'>"
response.write "var clientsideArray() = new Array()"
Do Until mD.Eof
response.write "clientsideArray(i++) = '" & mD("imgName") & "'"
mD.MoveNext
Loop
response.write "</script>"
[close the database]
%>
======================================================
 
A

Andrew

Try this:

<script language="JavaScript">
<!--
var bannerNum = 1;
function rotateBanner() {
if (++bannerNum > 4)
bannerNum = 1;
document.images["pics"].src = "images/" + bannerNum + ".gif";
window.setTimeout('rotateBanner();', 5000);
}
//-->
</script>
<img name="pics" src="images/1.gif" >
 
E

Evertjan.

Andrew wrote on 14 okt 2005 in microsoft.public.inetserver.asp.general:
Try this:

<script language="JavaScript">
<!--
var bannerNum = 1;
function rotateBanner() {
if (++bannerNum > 4)
bannerNum = 1;
document.images["pics"].src = "images/" + bannerNum + ".gif";
window.setTimeout('rotateBanner();', 5000);
}
//-->
</script>
<img name="pics" src="images/1.gif" >


Sehboo said:
I don't know if this will work. How can I call asp function from
javascript? If that is possible then I can just call database from my
asp function.

[please do not toppost on usenet]

Andrew, where do you answer the ASP question?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top