[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 11-05-2007, 06:31 AM   #1 (permalink)
NamePros Regular
 
John84's Avatar
 
Join Date: Apr 2006
Posts: 267
4.50 NP$ (Donate)

John84 is an unknown quantity at this point


image rotate script

Hi All,

using the following javascript code to randomly rotate images...

Code:
<!-- Begin
var interval = 2.5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("http://www.website.com/images/pic1.jpg");
image_list[image_index++] = new imageItem("http://www.website.com/images/pic2.jpg");
image_list[image_index++] = new imageItem("http://www.website.com/images/pic3.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
//  End -->
...however, I no longer want it random and would like it to go in order. Can this be done with this peice of code?
John84 is offline  
Old 11-06-2007, 05:42 PM   #2 (permalink)
NamePros Member
 
sote's Avatar
 
Join Date: Jul 2006
Posts: 70
13.20 NP$ (Donate)

sote will become famous soon enoughsote will become famous soon enough


Simple, just change the value of random_display on line 3 from 1 to 0.
__________________
woosah!
sote is offline  
Old 11-06-2007, 05:44 PM   #3 (permalink)
Senior Member
 
TheWatcher's Avatar
 
Join Date: May 2003
Location: HARDWORKING.COM
Posts: 3,306
636.00 NP$ (Donate)

TheWatcher is a splendid one to beholdTheWatcher is a splendid one to beholdTheWatcher is a splendid one to beholdTheWatcher is a splendid one to beholdTheWatcher is a splendid one to beholdTheWatcher is a splendid one to beholdTheWatcher is a splendid one to behold


Quote:
Originally Posted by sote
Simple, just change the value of random_display on line 3 from 1 to 0.
I'm about to say that.
__________________
Start your own domain business visit http://RESELLER.KING.NET
My Blog KING.NET daily updates. http://www.twitter.com/KingNET
DNCon.com - Domaining for Business!. FREE Service for all.
Moscom.com 24x7 Web Hosting (480) 624-2500. Michigan.TV SM.TV
TheWatcher is offline  
Old 11-06-2007, 11:04 PM   #4 (permalink)
NamePros Regular
 
John84's Avatar
 
Join Date: Apr 2006
Posts: 267
4.50 NP$ (Donate)

John84 is an unknown quantity at this point


that seems to stop the script all together
John84 is offline  
Old 11-07-2007, 03:31 AM   #5 (permalink)
New Member
 
Join Date: Nov 2005
Posts: 6
0.00 NP$ (Donate)

LovesYou is an unknown quantity at this point


Quote:
Originally Posted by John84
that seems to stop the script all together
How does the code look now?
LovesYou is offline  
Old 11-07-2007, 07:30 PM   #6 (permalink)
NamePros Regular
 
John84's Avatar
 
Join Date: Apr 2006
Posts: 267
4.50 NP$ (Donate)

John84 is an unknown quantity at this point


I ended up just finding a different script altogether to accomplish what I needed. This thread can be closed. Thanks for those who offered help.
John84 is offline  
Old 11-10-2007, 12:04 PM   #7 (permalink)
Account Closed
 
Join Date: Aug 2007
Posts: 24
0.00 NP$ (Donate)

Mystery is an unknown quantity at this point


I have a very cool image script, probably the BEST! PM me for details.
Mystery is offline  
Old 11-11-2007, 06:43 AM   #8 (permalink)
NamePros Member
 
Join Date: Mar 2006
Posts: 139
57.70 NP$ (Donate)

leusmith is an unknown quantity at this point


My friend... if you dont want to mess with code then use a good site that provides image rotator services... There are many good ones(and many are free too).

I also know one of my friends who started a site called imagerotation.com.
There are many users on the site and its simple too... so try it...

But if you want to offer a service where your users choose the images, then his site wont work for you...

Also try the YUI... thats the Yahoo User Interface library... Its a free download from developer.yahoo.com
leusmith is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:05 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85