Click to See Complete Forum and Search --> : Rotating Randomizer
blulady
02-10-2003, 07:31 AM
Hello! I need some help please, I have a slideshow script that displays 1 pic, I need to be able to have a bank of 4 side by side, any ideas? (all 4 need to be from a diff group of photos).
<script language="JavaScript1.2">
var number_of_slideshows=1
var interval=3000
var linked=1
for (i=0; i <number_of_slideshows; i++)
slideshows[i]=new Array()
slideshows[0][0]='http://members.localnet.com/~blulady/pic/495-1.jpg'
slideshows[0][1]='http://members.localnet.com/~blulady/pic/496-1.jpg'
slideshows[0][2]='http://members.localnet.com/~blulady/pic/497-1.jpg'
slideshows[0][3]='http://members.localnet.com/~blulady/pic/498-1.jpg'
slideshows[0][4]='http://members.localnet.com/~blulady/pic/499-1.jpg'
slideshows[0][5]='http://members.localnet.com/~blulady/pic/500-1.jpg'
slideshows[0][6]='http://members.localnet.com/~blulady/pic/501-1.jpg'
slideshows[0][7]='http://members.localnet.com/~blulady/pic/502-1.jpg'
slideshows[0][8]='http://members.localnet.com/~blulady/pic/503-1.jpg'
var slidelinks=new Array(number_of_slideshows)
for (i=0; i <number_of_slideshows; i++)
slidelinks[i]=new Array()
slidelinks[0][0]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2307453676'
slidelinks[0][1]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2307453874'
slidelinks[0][2]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2307454209'
slidelinks[0][3]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2307454464'
slidelinks[0][4]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2158862997'
slidelinks[0][5]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2158863935'
slidelinks[0][6]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2158864747'
slidelinks[0][7]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2810513486'
slidelinks[0][8]='http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=2810514155'
function clickredir(){
window.location=slidelinks[maininc][subinc]
}
var maininc=0
var subinc=0
if (linked)
document.write('<a href="javascript:clickredir()"><img src="'+slideshows[0][0]+'" name="multislide" border=0></a>')
else
document.write('<img src="'+slideshows[0][0]+'" name="multislide">')
function slideit(){
subinc= (subinc<slideshows[maininc].length-1)? subinc+1: 0
document.images.multislide.src=slideshows[maininc][subinc]
}
function setslide(which){
clearInterval(runit)
maininc=which
subinc=0
runit=setInterval("slideit()",interval)
}
runit=setInterval("slideit()",interval)
</script>
blulady
02-10-2003, 10:27 AM
Can anyone help?
khaki
02-10-2003, 11:06 AM
Hi Blulady
I'm sure that this isn't what you particularly want to hear (I didn't either, until I saw the light .... or was shown the light), but why don't you use animated gifs?
Then you can put 4 (or as many as you want) and you won't have to figure out how to modify and quadruple this code (which I am going to guess is not written by you).
It's just a suggestion.
(and no wonder your blue… that code knocked the air out of me. You sure you want 4 times that amount when you can just use 4 img tags!?)
Good luck.
k
blulady
02-10-2003, 11:55 AM
I need to display approx. 50-100 images in total. I would like to divide them up into 4 or 5 batches so that I would end up with 4 or 5 rotating pictures at all times. The pictures need to be clickable and linked to a URL.
Regardless of the exact reason for using this feature of Javascript, and for me personally since I'm fairly new to Javascript just the learning "how to" is reason enough to pursue this.
I seem to have a pretty good example of how to use setTimeout to fire a function every so often - I'd be happy with every second for learning purposes right now. My understanding is that setTimeout can be used to defer the execution rather than for my purposes, but the example has the function calling setTimeout and does document this will refire itself every mintue I believe. What I'm trying to run is below.
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive 5">
<title>Welcome to Adobe GoLive 5</title>
<script language="Javascript" >
function SwapManager()
{
window.alert("You must enter your name");
setTimeout("SwapManager()",1000);
}
</script>
</head>
<body bgcolor="#ffffff" onload="SwapManager();">
</body>
I've also tried similair with the aforementioned setInterval but still no luck. For the above code when I open the browser get the alert message and then oddly some time later(I'm an optimist lets call it a second) an "error on page occurs". IE tells me the error is an "object expected". I'm running IE 6.0 which frankly is behaving oddly. As you might infer from above I don't have the latest stuff.
If this is something which should just work that would be great to know because it certainly could be a more systemic problem. If anybody would like to help educate a snow bound New Englander on how to get either setTimeout() or setInterval() to work it would be great !!!
khalidali63
02-17-2003, 08:27 AM
Originally posted by Jay5
....... I'm running IE 6.0 which frankly is behaving oddly.........
Unless you have overlooked posting rest of the JavaScript code here,the above piece of code I used with IE6 and NS6+ browsers with a tiny bit of variation so that it won't run forever.
<script type="text/javascript">
var ctr=0;
function SwapManager(){
if(ctr<4){
ctr++;
window.alert("You must enter your name");
setTimeout("SwapManager()",1000);
}
}
</script>
</head>
<body bgcolor="#ffffff" onload="SwapManager();">
It works exactly the way it should.
Difference between setTimeout and setInterval
# setTimeout() allows you to DELAY the execution of an expression or evaluate a function.
# setInterval() allows you to EVALUATE an expression or a function at set INTERVALS
There is tonne of info ,just do a search on google with this phrase
"difference between setTimeout and setInterval"
Hope this helps
Cheers
Khalid
khaki
02-17-2003, 11:26 AM
Hi again blulady -
Sorry for misunderstanding what you were looking to do (and then forgetting to get back to you afterwards.
oops. I think that I'm getting ditzy-er with every passing moment. lol).
OK, so I'm buried under more than a foot of snow already, so I played-around with something that maybe
you could use (and I make no claims to being a Javascript expert, so I'll leave it to the masters to shred it
and patch it back together, if necessary).
It works - that's all I can promise (although you'll need to add onto it for your specific needs. I hope I made
it obvious enough how to do that by the way that I set it up).
Well, like I said... I'm no expert, but here goes:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<style type="text/css">
<!--
#group1 {position:absolute; top:25px; left:25;}
#group2 {position:absolute; top:200px; left:100;}
-->
</style>
<script LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
// 1st group of images and url's
group1Imgs = new Array("http://forums.webdeveloper.com/img/webdevlogoz.gif","http://javascript.internet.com/img/headerlogo.gif","http://htmlgoodies.com/images/masthead_goodies.gif")
group1URL = new Array("http://www.webdeveloper.com/","http://www.htmlgoodies.com","http://javascript.internet.com/")
group1this = 0
group1imgCount = group1Imgs.length
function rotateGroup1() {
if (document.images) {
if (document.group1image.complete) {
group1this++
if (group1this == group1imgCount) {
group1this = 0
}
document.group1image.src=group1Imgs[group1this]
}
setTimeout("rotateGroup1()", 3 * 1000)
}
}
function URLgroup1() {
document.location.href = group1URL[group1this]
}
// 2nd group of images and url's
group2Imgs = new Array("http://forums.webdeveloper.com/avatar.php?userid=2767&dateline=1045337313","http://forums.webdeveloper.com/avatar.php?userid=37&dateline=1037846688","http://forums.webdeveloper.com/avatar.php?userid=728&dateline=1044989394","http://www.j-moriarty.co.uk/jm1.jpg")
group2URL = new Array("http://www.agentprovocateur.com/site/","http://www.DaveClarkConsulting.com","http://www.infinitypages.com","http://www.j-moriarty.co.uk")
group2this = 0
group2imgCount = group2Imgs.length
function rotateGroup2() {
if (document.images) {
if (document.group2image.complete) {
group2this++
if (group2this == group2imgCount) {
group2this = 0
}
document.group2image.src=group2Imgs[group2this]
}
setTimeout("rotateGroup2()", 5 * 1000)
}
}
function URLgroup2() {
document.location.href = group2URL[group2this]
}
// repeat for each group and don't forget to add the functions to the onLoad and A HREF areas.
// ........ and pay no mind to my little link. sometimes a girl just likes to have fun y'know!
</SCRIPT>
</HEAD>
<body onLoad="rotateGroup1(); rotateGroup2()">
<div id="group1">
<a HREF="javascript:URLgroup1()"><img SRC="http://javascript.internet.com/img/headerlogo.gif" NAME="group1image" BORDER="0"></a>
</div>
<div id="group2">
<a HREF="javascript:URLgroup2()"><img SRC="http://forums.webdeveloper.com/avatar.php?userid=728&dateline=1044989394" NAME="group2image" BORDER="0"></a>
</div>
</BODY>
</HTML>
OK "experts" .... be easy on me. I'd be happy to hear how to write this "correctly". I am only trying to do like
Jay5 says and work it out for myself to try to learn (and while I admit that I rifled most of the code from all
over the world wide web, I didn't use anything that I myself didn't understand - at least conceptually).
Well anyway blulady, I think this is what you wanted to do (and it works - even if it is all made up of duct-tape
and paper-clips). Let the experts do as they will with it. I'll be following closely to see what more comes of it.
the girly MacGyver of the internet,
k
blulady
02-17-2003, 11:45 AM
Thanks so much for the help! I don't know if it will work though. What this is for is to put a 'showcase' at the bottom of my ebay auction listings (I currently insert a table with clickable thumbs, just trying to cut down on my work with a random). The prob is I am unable to access the <head>. Any ideas?
khaki
02-17-2003, 12:14 PM
OH.
You should have said that this wasn't a straight-forward HTML thing (I have no clue about eBay).
I also now realize that I've got 2 BODY tags in my code, and I closed my HEAD tag in the wrong place
(UGH! That's just WAAAAAY too sloppy!). I'll edit it right after this response.
Well anyway, I'm not an eBay person, but you really should have mentioned that up-front so that the
solution could be configured with all of the eBay conditions addressed accordingly (whatever those are).
I'm not sure that you can do what you are looking to do if you can't access the HEAD of the document,
but I'll let the Javascript/eBay folks (if any exist) handle that.
Sorry. I STILL haven't solved your issue. But I'll keep following to see how it gets resolved.
Good luck.
the SLOPPY and girly MacGyver of the internet,
k
Just to close the loop here and provide some clarity to my above. Yes to be totally truthful I did NOT post the exact code that was giving me the Object Expected error. I was doing a"document.write("test message");" like
document.write("test message");
window.alert("You must enter your name");
I don't know why I guess the docment.write was my initial thinking as to see if this was working at all, and I guess from then on out I was just all hosed up. Anyway with document.write - ERROR, without NO ERROR. Interesting riddle but one I really don't need an answer to I've got what I needed. As for the IE 6.0 flakyness, this whole system is flaky and due for an upgrade but doesn't look like a contributing factor.
The code posted above with the for counter worked great and I've seen other posts with people having trouble with these functions.
Snow is effecting my brain to probably just should've just started my own discussion on this, but it just seemed nobody was have any luck with these functions.