By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,071 Members | 1,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,071 IT Pros & Developers. It's quick & easy.

Rotating pictures

P: n/a
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.

Oct 13 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 13 '05 #2

P: n/a
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];
}

Oct 13 '05 #3

P: n/a
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.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 13 '05 #4

P: n/a
I have SQL Server.

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

Oct 13 '05 #5

P: n/a
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">
"Sehboo" <ma*********@hotmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
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];
}

Oct 13 '05 #6

P: n/a
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.

Oct 13 '05 #7

P: n/a
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]
%>
================================================== ====

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 13 '05 #8

P: n/a
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" <ma*********@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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.

Oct 14 '05 #9

P: n/a
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" <ma*********@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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?
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 14 '05 #10

P: n/a
something like www.aspbanner.com can rotate pictures, any code or text
actually according to the docs
"Sehboo" <ma*********@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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.

Dec 5 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.