?
Solved

ASP image rotator on a timer looping through database records

Posted on 2009-04-11
11
Medium Priority
?
489 Views
Last Modified: 2012-05-06
I've searched for the answer but it's a hard one to search for.  I need an image rotator that will loop through my database of images, display and automatically change every five seconds or so.  My folder name is rotator/prizes and the images are uploaded through a content editor and the names are stored in an access database.  A javascript/ASP solution would be ideal.  I'm better at ASP than Javascript.  Any thoughts will be greatly appreciated.  Thanks in advance.
0
Comment
Question by:meldraper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24123971
not sure but, in order for you to do something like that you would need to have it done
In a FRAME (or) IFRAME. ( I would think )

NOW.
You can set it up to Refresh every so many seconds.
And use this code that I made up for another user

http://ee.cffcs.com/Q_24265323/1.asp
http://ee.cffcs.com/Q_24265323/Q_24265323.zip

The only think that you would need to add in a
<meta refresh>
For 5 seconds.

Let me know if this is something that you would like to have.
And I will help you to add in the refresher....

Carrzkiss
0
 

Author Comment

by:meldraper
ID: 24124031
I LOVE IT.  Let me mess around with it for a while and maybe I can figure out the refresh myself.  Many thanks for this.  I really appreciate it.  I will let you know either way.
0
 

Author Comment

by:meldraper
ID: 24130158
Hi Carrzkiss, I worked with the script and I have a few quesitons.  I notice that "undefined" comes up a lot.  I have three images.  I set line 36 to 4 instead of 59 since I didn't have that many.  I put the refresh code in for every 5 seconds.  Take a look at this and help me figure out what I'm doing wrong.  Also, is there a way for it not to randomize?  Many thanks.

http://weddingfairshow.com/untitled/1.asp


<html>
<meta HTTP-EQUIV="Refresh" CONTENT="5; url=1.asp">
<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("Q_24265323.mdb") & ";"
objConn.Open
getS = Request.QueryString("ID")
Set objRs=Server.CreateObject("ADODB.RecordSet")
getSQL = "select id, FileName, ImageTitle FROM ImageTable ORDER BY ID ASC"
objRs.Open getSQL, objConn, 1, 1, 1
%>
<style type="text/css">
#image
{
border: 1px solid #000;
}
 
</style>
<script type="text/javascript">
//The array which is going to hold the image information. Store the image info along with their correct path; I've omitted the path here as I've stored the images in the same folder where my web page resides.
var imageArray = new Array();
var imageID = new Array();
var imageTitle = new Array();
 
 <%While Not objRs.EOF%> 
imageArray[<%=objRs("id")%>] = "images/<%=objRs("FileName")%>"; 
imageID[<%=objRs("id")%>] = "<%=objRs("id")%>";
imageTitle[<%=objRs("id")%>] = "<%=objRs("ImageTitle")%>";
<%
 objRs.MoveNext
    Wend
%>
function doIt()
{
var rand = Math.floor(Math.random()*4); //we have 58 images in the database, so we set the # to 59
 
var imgPath = "<a href='"+imageArray[rand]+"' target='_blank'><img src='"+imageArray[rand]+"' alt='"+imageArray[rand]+"' border='0' align='absmiddle' width='400' height='285' /></a>";
var imgID = "Image ID is: "+imageID[rand]+". <a href='javascript:history.go(0)'>Refresh page</a><br />"
var imgTit = ""+imageTitle[rand]+""
 
document.getElementById("image").innerHTML = imgPath;
document.getElementById("imageID").innerHTML = imgID;
document.getElementById("imageTitle").innerHTML = imgTit; 
}
</script>
</head>
 
<body>
Click image to see it's actual size<br/>
<div id="image" style="width:400px;"></div>
<div id="imageID"></div>
<div id="imageTitle"></div>
<script type="text/javascript">
doIt();
</script>
 
</body>
</html>
<%
    objRs.Close
    Set objRs=Nothing
%>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24131185
there is no way to not randomize. Unfortunantly.

In my demo, I found the same issue of: undefined.
Once it got past the amount of images that was listed in the database.
I changed the # to the exact number of images in the database, and that fixed it in my Demo.
BUT, When I changed the # from 4 - to - 3
In your demo, it still showed me the same error.

Right now, I am unsure as to why it is doing it on yours and not with mine.

With mine, I am thinking that setting to 59 when there is 58 records in the database, would cause this issue.

See, this script was not like this when I found it, I changed it to work with a Database.
So, I am unsure as how to fix it?

I will do some more checking on this later on today, as I am getting ready to leave for a while.

Change your # from 4 to 3
And play around with it, and see what you can find out.

Carrzkiss
0
 

Author Comment

by:meldraper
ID: 24131207
Will do, and thanks again.  No big deal on the randomizer, either.
0
 

Author Comment

by:meldraper
ID: 24347952
carrzkiss, I was not able to use this because of the "undefined" thing, so I'm going to just delete the question.  I'll have to figure out another way.  Please reply so I can either delete the question or work with another fix you might have.  Many thanks.
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24349086
Instead of deleting, lets look at a few other codes here.

http://weblog.sitepros.net/journal_comments.asp?JournalID=79
This is an ASP Image Rotator.
Use it in the same way that you did mine, with the page refreshing every how often you desire.

See if it will work for you.
Look pretty nice.

Carrzkiss
0
 

Accepted Solution

by:
meldraper earned 0 total points
ID: 24776673
Carrzkiss,

I'm going to use Flash with an XML backend instead.  I can programmatically manipulate the XML file.  Thank you very much for your help, though.

Melissa
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24777686
Sounds good.
Good Luck with it.

Have a happy 4th of July.

Carrzkiss
0
 

Author Comment

by:meldraper
ID: 24777696
You, too.  And just look at us, we are working!!
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 24777751
Yep.
I have to release my new site on Monday, so I will most likely work through-out the day.
I have my son right beside me on the other Computer chatting with friends.
So, that is good enough for me.
Next year will be a better time to celebrate, not right now, to much to do.

Good Luck
Carrzkiss
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question