473,503 Members | 7,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help changing current slideshow code

i currently use the code below to create a slideshow of images. i
edited it so that its not as long. i currently have over 20 images

i want to change it so that the images dont appear in the same order
each time. what would i have to change to make the cycle random???
thanks in advance for the help.

gabriel

-- heres the code --
<script language="JavaScript1.1">
<!--

//specify interval between slide (in mili seconds)
var slidespeed=100

//specify images
var slideimages=new Array("images/slideshow/comp_logo.gif",
"images/slideshow/logo2.gif", "

//specify corresponding links
var slidelinks=new Array("http://www.company.com",
"http://www.mycompany.com/

var newwindow=1 //open links in new window? 1=yes, 0=no

var imageholder=new Array()
var ie=document.all
for (i=0;i<slideimages.length;i++){
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}

function gotoshow(){
if (newwindow)
window.open(slidelinks[whichlink])
else
window.location=slidelinks[whichlink]
}
function openwindow()
{
window.open("http://cmis.tamu.edu/web/video.asp","my_new_window","toolbar=no,
location=no, directories=no, status=no, menubar=no, scrollbars=no,
resizable=no, copyhistory=no, width=700, height=600")
}
//-->
</script>

Jul 5 '06 #1
8 1514

Ga**************@gmail.com wrote:
i currently use the code below to create a slideshow of images. i
edited it so that its not as long. i currently have over 20 images

i want to change it so that the images dont appear in the same order
each time. what would i have to change to make the cycle random???
thanks in advance for the help.

gabriel

-- heres the code --
<script language="JavaScript1.1">
<!--

//specify interval between slide (in mili seconds)
var slidespeed=100

//specify images
var slideimages=new Array("images/slideshow/comp_logo.gif",
"images/slideshow/logo2.gif", "

//specify corresponding links
var slidelinks=new Array("http://www.company.com",
"http://www.mycompany.com/

var newwindow=1 //open links in new window? 1=yes, 0=no

var imageholder=new Array()
var ie=document.all
for (i=0;i<slideimages.length;i++){
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}

function gotoshow(){
if (newwindow)
window.open(slidelinks[whichlink])
else
window.location=slidelinks[whichlink]
}
function openwindow()
{
window.open("http://cmis.tamu.edu/web/video.asp","my_new_window","toolbar=no,
location=no, directories=no, status=no, menubar=no, scrollbars=no,
resizable=no, copyhistory=no, width=700, height=600")
}
//-->
</script>
Dear sir,
You will have to either implement an algorithm in order to randomize
the pattern, or else you can make "i" with the random number (multiply
the result of this function by ten) and ceiling functions, along with
an if loop that makes sure that "i", being a random number, is not
larger than the index of the last image in the array.

I have the honor to remain your most humble and Ob't Sv't in our war
against the King.

--
Patrick Reilly
1st Coy.
Colonel Seth Warner's Regiment

Jul 6 '06 #2
JRS: In article <11**********************@m79g2000cwm.googlegroups .com>
, dated Thu, 6 Jul 2006 08:43:31 remote, seen in
news:comp.lang.javascript, pe********************@gmail.com <pegasusflig
ht*********@gmail.composted :
>
Ga**************@gmail.com wrote:
>i currently use the code below to create a slideshow of images. i
edited it so that its not as long. i currently have over 20 images

i want to change it so that the images dont appear in the same order
each time. what would i have to change to make the cycle random???
thanks in advance for the help.
>//specify images
var slideimages=new Array("images/slideshow/comp_logo.gif",
"images/slideshow/logo2.gif", "
>You will have to either implement an algorithm in order to randomize
the pattern, or else you can make "i" with the random number (multiply
the result of this function by ten) and ceiling functions, along with
an if loop that makes sure that "i", being a random number, is not
larger than the index of the last image in the array.

I have the honor to remain your most humble and Ob't Sv't in our war
against the King.
Incompetent advice; you should by now have read the newsgroup FAQ.

The image URLs are in an array slideimages and will be indexed from 0 to
slideimages.length-1.

A random integer in that range is given by Random(slideimages.length)
where Random in the function in FAQ 4.22.

There is no need to use Math.ceil, and multiplying by 10 is
inappropriate here, nor to loop through any checks.

It is a good idea to understand a topic before giving advice on it.

If course, if the OP is paid per line of code or in proportion to CPU
time used in execution then your method has some advantage.

If the OP's images are wisely named (which at present they appear not to
be) with a numeric part, then the array of names is not needed, since
the name can be computed.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 7 '06 #3

Dr John Stockton wrote:
JRS: In article <11**********************@m79g2000cwm.googlegroups .com>
, dated Thu, 6 Jul 2006 08:43:31 remote, seen in
news:comp.lang.javascript, pe********************@gmail.com <pegasusflig
ht*********@gmail.composted :

Ga**************@gmail.com wrote:
i currently use the code below to create a slideshow of images. i
edited it so that its not as long. i currently have over 20 images

i want to change it so that the images dont appear in the same order
each time. what would i have to change to make the cycle random???
thanks in advance for the help.
//specify images
var slideimages=new Array("images/slideshow/comp_logo.gif",
"images/slideshow/logo2.gif", "
You will have to either implement an algorithm in order to randomize
the pattern, or else you can make "i" with the random number (multiply
the result of this function by ten) and ceiling functions, along with
an if loop that makes sure that "i", being a random number, is not
larger than the index of the last image in the array.

I have the honor to remain your most humble and Ob't Sv't in our war
against the King.

Incompetent advice; you should by now have read the newsgroup FAQ.

The image URLs are in an array slideimages and will be indexed from 0 to
slideimages.length-1.

A random integer in that range is given by Random(slideimages.length)
where Random in the function in FAQ 4.22.

There is no need to use Math.ceil, and multiplying by 10 is
inappropriate here, nor to loop through any checks.

It is a good idea to understand a topic before giving advice on it.

If course, if the OP is paid per line of code or in proportion to CPU
time used in execution then your method has some advantage.

If the OP's images are wisely named (which at present they appear not to
be) with a numeric part, then the array of names is not needed, since
the name can be computed.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Dear sir,
Thank you for the correction. I had not known of the parameter in the
random function.

I have the honor to remain your most humble and Ob't Sv't in our war
against the King

--
Patrick Reilly
1st Coy.
Colonel Seth Warner's Regiment

Jul 10 '06 #4
JRS: In article <11*********************@h48g2000cwc.googlegroups. com>,
dated Mon, 10 Jul 2006 10:45:15 remote, seen in
news:comp.lang.javascript, pe********************@gmail.com <pegasusflig
ht*********@gmail.composted :
>Lines: 72
>Dr John Stockton wrote:
>Incompetent advice; you should by now have read the newsgroup FAQ.
>Thank you for the correction. I had not known of the parameter in the
random function.
From your article formatting, it is evident that you have still not
studied the newsgroup FAQ. Only a fool would presume to give advice
without having done so, checking each time what the FAQ actually says.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 11 '06 #5
i know this topic has been dead for awhile but i have a followup
question. instead of making the images go in a random order is there a
way to make the starting point random instead instead of starting on
image 1.

thanks for all the help ive gotten so far on the topic

gabriel

Jul 12 '06 #6

Ga**************@gmail.com wrote:
i know this topic has been dead for awhile but i have a followup
question. instead of making the images go in a random order is there a
way to make the starting point random instead instead of starting on
image 1.

thanks for all the help ive gotten so far on the topic

gabriel
Dear sir,
That is, in effect, what the whole concept of using the Random function
is. It creates a random positive number (in the case that you put a
parameter, it uses the parameter as a boundary) and you can use that
random number as the start. If you want the starting point to be
random, but the rest of the order not to be, then you will have to have
the index of the array start with a number generated by the random
function, but then have the random number increment each time the
timeout, or interval goes off. I'm sorry for not putting any code in
here, but I hope you get the concept.

I have the honor to remain your most humble and Ob't Sv't in our war
against the King.

--
Patrick Reilly
1st Coy.
Colonel Seth Warner's Regiment

Jul 13 '06 #7
JRS: In article <11**********************@p79g2000cwp.googlegroups .com>
, dated Thu, 13 Jul 2006 11:51:59 remote, seen in
news:comp.lang.javascript, pe********************@gmail.com <pegasusflig
ht*********@gmail.composted :
>
Ga**************@gmail.com wrote:
>i know this topic has been dead for awhile but i have a followup
question. instead of making the images go in a random order is there a
way to make the starting point random instead instead of starting on
image 1.
Neater to start with image 0.
>thanks for all the help ive gotten so far on the topic

gabriel

Dear sir,
That is, in effect, what the whole concept of using the Random function
There is no Random function in Javascript as defined by ECMA or
implemented generally by manufacturers. There is a Method, Math.random;
a function Random is given in the newsgroup FAQ, but you did not cite
that.
>is. It creates a random positive number (in the case that you put a
It creates a random non-negative integer ... Zero is not positive.
>parameter, it uses the parameter as a boundary) and you can use that
Boundary is hardly a good description, since it cannot be reached.
>random number as the start. If you want the starting point to be
random, but the rest of the order not to be, then you will have to have
the index of the array start with a number generated by the random
function,
Array indices start at zero; what you have written does not express your
probable meaning.
but then have the random number increment each time the
timeout, or interval goes off.
That's not good enough for an array of finite length unless the run is
correspondingly limited.
I'm sorry for not putting any code in
here,
That's probably your wisest move.
but I hope you get the concept.

<URL:http://www.merlyn.demon.co.uk/js-date2.htm#RCdoes substantially
what the OP wants - between "Dynamic" & "Graphic" - except that the mane
of the image is generated by concatenation in GetFigs and the images are
loaded into Figs for run-time indexing.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 14 '06 #8

Dr John Stockton wrote:
JRS: In article <11**********************@p79g2000cwp.googlegroups .com>
, dated Thu, 13 Jul 2006 11:51:59 remote, seen in
news:comp.lang.javascript, pe********************@gmail.com <pegasusflig
ht*********@gmail.composted :

Ga**************@gmail.com wrote:
i know this topic has been dead for awhile but i have a followup
question. instead of making the images go in a random order is there a
way to make the starting point random instead instead of starting on
image 1.

Neater to start with image 0.
thanks for all the help ive gotten so far on the topic

gabriel
Dear sir,
That is, in effect, what the whole concept of using the Random function

There is no Random function in Javascript as defined by ECMA or
implemented generally by manufacturers. There is a Method, Math.random;
a function Random is given in the newsgroup FAQ, but you did not cite
that.
And yet you cited it in your response to my use of the random function
corresponding to the random method of Math without the parameter. Is
that not enough of a citation?
>
is. It creates a random positive number (in the case that you put a

It creates a random non-negative integer ... Zero is not positive.
parameter, it uses the parameter as a boundary) and you can use that

Boundary is hardly a good description, since it cannot be reached.
That all depends on your visualization, or definition of a boundary.
>
random number as the start. If you want the starting point to be
random, but the rest of the order not to be, then you will have to have
the index of the array start with a number generated by the random
function,

Array indices start at zero; what you have written does not express your
probable meaning.
I was speaking of the index that is the starting point of the loop for
the slideshow. This would use an integer and therefore put it as the
selected index to start the slideshow at. True, array indices start at
zero, but array indices can be used to select, therefore letting the
starting point of the _slideshow_ be the index generated by the Random
method/function.
>
but then have the random number increment each time the
timeout, or interval goes off.

That's not good enough for an array of finite length unless the run is
correspondingly limited.
In effect, the manner I am telling the OP of is exactly that. "of
finite length" and "correspondingly limited".
>
I'm sorry for not putting any code in
here,

That's probably your wisest move.
but I hope you get the concept.


<URL:http://www.merlyn.demon.co.uk/js-date2.htm#RCdoes substantially
what the OP wants - between "Dynamic" & "Graphic" - except that the mane
of the image is generated by concatenation in GetFigs and the images are
loaded into Figs for run-time indexing.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
I still don't understand why people must insult or demote others
because of simple mistakes. Everyone makes them, and the more you
make, the more successful you will be. If you wish for proof, I will
willingly answer you as long as you e-mail me.

I have the honor to remain your most humble and Ob't Sv't in our war
against the King.

--
Patrick Reilly
1st Coy.
Colonel Seth Warner's Regiment

Jul 16 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1644
by: Patrick Fitzgerald | last post by:
I have a GNU licensed Javascript slideshow script: http://slideshow.barelyfitz.com/ Recently some users have complained about problems in Mac IE; unfortunately I don't have a Mac system that I...
16
2854
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
5
2043
by: TrvlOrm | last post by:
HI There, I have been struggling with JavaScript code for days now, and this is my last resort! Please help... I am trying to create a JavaScript slide show with links for Next Slide,...
1
1507
by: scorpion53061 | last post by:
I really like this javascript for an image slideshow. The only thing I woudl like to do differently is have a cell above the image and navigation that would allow text content to be placed. Does...
8
2018
by: drillbit_99 | last post by:
I have an HTML page of thumbnail images. Each image can begin a slideshow of the images on the page by clicking on the image. This opens another HTML page that begins the slideshow using large...
22
5096
by: bevoldjling | last post by:
Hi ! I need some help in putting together a website for our family gathering. Although I'm still pretty "green", I don't think what I need requires terribly advanced skills ...except for one...
6
2378
by: mrtaka79 | last post by:
Okay, first of all, I'm a complete noob, so go easy on me. I have this code that works perfectly for me. The only thing I want to add is to randomize the pictures/links that show up. Can anyone...
2
3125
pradeepjain
by: pradeepjain | last post by:
script> // (C) 2000 www.CodeLifter.com // http://www.codelifter.com // Free for all users, but leave in this header // NS4-6,IE4-6 // Fade effect only in IE; degrades gracefully //...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.