473,382 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

slide-show (random images)?

I would like to make a slide show using random images. The problem is my
host is 250.com, and they don't support cgi-programs. Is there another
way to accomplish random images?

Jul 23 '05 #1
9 12123
Michael Burtenshaw wrote:
I would like to make a slide show using random images. The problem is my
host is 250.com, and they don't support cgi-programs. Is there another
way to accomplish random images?

www.dynamicdrive.com

I thought 250.com went out of the hosting business.
Since I now get a website for "micropatent".
Jul 23 '05 #2
Michael Burtenshaw wrote on 19 dec 2004 in comp.lang.javascript:
I would like to make a slide show using random images. The problem is my
host is 250.com, and they don't support cgi-programs. Is there another
way to accomplish random images?


Clientside scripting, surely.

You uploading a different page every 5 minutes,
works as long as you don't fall asleep.

Serverside scripting, like ASP or PHP, if on your ISP.
[No, I don't want to have a look at your ISP's specs]

CGI-programming is not a primary method for such simple tasks, IMHO.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #3
On Sun, 19 Dec 2004 00:02:18 -0500, Mi***************@webtv.net
(Michael Burtenshaw) wrote:
I would like to make a slide show using random images. The problem is my
host is 250.com, and they don't support cgi-programs. Is there another
way to accomplish random images?

Michael,

I have been working on a client-side script to automatically loop
though mulitple sets of images. Each slide is name with a sequential
number such as myImage1.jpg, myImage2.jpg myImage3.jpg. This
lets me us a "for loop" in the preload images into an Array, then I
can sequential step through the images by incrementing the counter
(currImg++). To randomly select the next image use....
currImg = Math.round(Math.random()*maxImg)
Here is a greatly simplified example of my script. I have stripped
off a lot of functions/buttoms, such First, Last, Prev, FrameRate and
the ability for the user to select different set of images.

Good Luck,
Ron Beitel
//***** SlideShow_Random.html ******

<html>
<head>

// ron beitel, 20 Dec 2004

<script language="JavaScript">

var delay = 500 // 1000 is 1 sec.
var currImg = 0 // index to the current image
var maxImg = 25 // default number of images (0 to 24)
var tid // timeout Id

var pix = new Array()

function preloadImgSet(max) {
for (i=0;i<max;i++) {
pix[i] = new Image()
pix[i].src = "http://250.com/yourPath/image_" + i + ".jpg"
}

nxtSlide()
}

function nxtSlide() {
clearTimeout(tid)
currImg = Math.round(Math.random()*maxImg)
document.images.Slide.src = pix[currImg].src
tid = setTimeout('nxtSlide()', delay)
}

function loop() {
tid = setTimeout('nxtSlide()', delay)
}

function stop() {
clearTimeout(tid)
}

function next() {
currImg = Math.round(Math.random()*maxImg)
document.images.Slide.src = pix[currImg].src
}

</script>

</head>

<body onLoad="preloadImgSet(maxImg)">
<table border>
<tr><td colspan=2 align=center>
<h2>My Slide Show</h2>
<h3>Loop or Step Randomly</h3>
</td></tr>

<tr><td><table border="0" cellpadding="0" cellspacing="0">

<tr><td align="center">
<img src="" name='Slide'>
</td></tr>

<tr align="center"><td>
<form name="buttons">
<input type="button" value="Loop" onclick="loop()"/>
<input type="button" value="Stop" onclick="stop()"/>
<input type="button" value="Next" onclick="next()"/>
</form>
</td></tr>

</table></td></tr>

</table>


</body>
</html>


Jul 23 '05 #4
On Sun, 19 Dec 2004 00:02:18 -0500, Mi***************@webtv.net
(Michael Burtenshaw) wrote:
I would like to make a slide show using random images. The problem is my
host is 250.com, and they don't support cgi-programs. Is there another
way to accomplish random images?

Michael,

If you don't want to sequential number your filenames, change the

function preloadImgSet() {
pix[0] = new Image(); pix[0].src = "yourURL/imageA.jpg";
pix[1] = new Image(); pix[1].src = "yourURL/imageB.jpg";
pix[2] = new Image(); pix[2].src = "yourURL/imageC.jpg";

I didn't want to explicitly list the 500+ image files in my SlideShow.

Hope this helps,
Ron Beitel
Jul 23 '05 #5
JRS: In article <iu********************************@4ax.com>, dated
Tue, 21 Dec 2004 23:27:10, seen in news:comp.lang.javascript, Ron Beitel
<ro**@not.here> posted :
To randomly select the next image use....
currImg = Math.round(Math.random()*maxImg)


Bad code - see FAQ.

--
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.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #6
On Wed, 22 Dec 2004 14:31:03 +0000, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:
JRS: In article <iu********************************@4ax.com>, dated
Tue, 21 Dec 2004 23:27:10, seen in news:comp.lang.javascript, Ron Beitel
<ro**@not.here> posted :
To randomly select the next image use....
currImg = Math.round(Math.random()*maxImg)


Bad code - see FAQ.

Oops!

What Doctor John is either to busy or to arrogant to explain
is my use of Math.round() instead of Math.floor().

In my example, currImg gets a value between 0 and 25 inclusive.
But the Array of images holds 25 images, numbered 0 to 24.

0 <= Math.round(Math.random()*x) <= x
0 <= Math.floor(Math.random()*x) < x
Also apparently some browsers (i.e. Opera) don't implement
the random function and return [0 .. 1.0] instead of [0 .. 1.0).
Use a modulus 1 to gaurd against this. So change the lines...

currImg = Math.floor((Math.random() % 1) * maxImg)


Jul 23 '05 #7
JRS: In article <v5********************************@4ax.com>, dated
Thu, 23 Dec 2004 02:10:58, seen in news:comp.lang.javascript, Ron
Beitel <ro**@not.here> posted :
On Wed, 22 Dec 2004 14:31:03 +0000, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:
JRS: In article <iu********************************@4ax.com>, dated
Tue, 21 Dec 2004 23:27:10, seen in news:comp.lang.javascript, Ron Beitel
<ro**@not.here> posted :
To randomly select the next image use....
currImg = Math.round(Math.random()*maxImg)


Bad code - see FAQ.

Oops!

What Doctor John is either to busy or to arrogant to explain
is my use of Math.round() instead of Math.floor().


When you use Math.round in that manner, you are not choosing at random.
The first and last options are only half as probable as the others.
Choosing at random, which is what the OP asked for, and what your
comment claims that you are doing, means that all possibilities must be
substantially equi-probable.

Posting an answer without a sufficient understanding of a newsgroup's
regularly-posted FAQ shows either arrogance or ignorance.

The regulars, of course, all know why it is bad code. The others should
read the FAQ. That is why we have a FAQ.

--
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.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #8
ron


Sorry!

I should not have been so rude, but I was annoyed by your curt reply.
Bad code - see FAQ.

This was not that helpful. It is true, I just started visiting here
last week. And until I saw the footer on your reply, I did not know
where to find the FAQ. I must say they are very informative. I was
really impressed and bookmarked them. I am sure they will be a great
asset as I try to learn JavaScript.

Your explanation was much more helpful, and I immediately understood
the your point.
When you use Math.round in that manner, you are not choosing at random.
The first and last options are only half as probable as the others.
Choosing at random, which is what the OP asked for, and what your
comment claims that you are doing, means that all possibilities must be
substantially equi-probable.


Since, at first, I misunderstood your reasoning, perhaps my irritation
was justified. I thought your objection was the possibility of
Math.round(...) giving 25, while pix[25] did not exist. I was more
embarassed by this novice mistake, then the fact that the
nonsequential display of slides would not be statistically random.

Finally, I must object to the implication that only the masters may
contribute here. I alway found a seminar more stimulating then a
lecture. Certianly, this dialog has thought me two important
lessions--the proper way to find a random number and to keep my foot
out of my mouth. I only posted my solution, because a previous reply
indicated it was necessary to use some server-side technique. Since I
am currently writing a script to sequentially loop through a set of
images, I checked either Goodman's or Flaganan's book for
Math.random(), and quickly modified currImg++. In the future, I
promise to think, proof-read and test before posting. (That reminds
me, I need to take a red pen to that book. I'm sure the example used
Math.round())

Please accept my apology and thanks.

Ron

Jul 23 '05 #9
JRS: In article <n9********************************@4ax.com>, dated
Thu, 23 Dec 2004 23:08:51, seen in news:comp.lang.javascript, ron
<ro*@bebop.inn> posted :

I should not have been so rude, but I was annoyed by your curt reply.


Longwindedness is an American custom not favoured elsewhere.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #10

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

Similar topics

1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
0
by: Ata | last post by:
Hello, I am trying to copy the contents of the output of SQL Reporting Services to a PowerPoint slide. For this, I am using SQL Reporting Services to obtain an IMAGE stream, which I paste to the...
2
by: WillRead | last post by:
I have a VB.Net application and a PowerPoint presentation explaining how each form in the application works, etc.. I would like to select and display the slide appropriate for each form by pressing...
1
by: Ganesh | last post by:
Where to find a right sided slide-in JavaScript? My idea is something like this http://www.dynamicdrive.com/dynamicindex1/davidmenu.htm But I need it right-sided, not left-sided... tia
0
by: redneon | last post by:
I'm trying to create a simple slide panel. Basically, what I've done is put a load of controls on a usercontrol and added this to a tabpage. The tabpage's height is 0 and when you move the mouse...
1
by: bsg92150 | last post by:
i have a task that requires me to provide a web use with the ability to send teh current page to a power point slide. and to further complicate matters. the user may want to put the whole site...
0
by: akshar108 via DotNetMonster.com | last post by:
Hi, I have aspose slide component and i want to take all string in the presentation's all slide but that component not give any method to get that direct we have to take all shape's textframe...
16
by: nagmvs | last post by:
Hi, Can any one tell me How to disable Keyboard Functions using JavaScript.If knows please tell me the code.Also tell me the code for mouse disable also. Thanks, Nagesh.
7
by: metaphysics | last post by:
For a portfolio I am trying to make, I would like to be able to have a couple thumbnails on the page, that, when clicked, cause a box to horizontally slide in above the thumbnails. I am looking to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.