Creating a Slide Show Using a Random Number Generator : Slide Show « Page Components « JavaScript DHTML

Home
JavaScript DHTML
1.Ajax Layer
2.Data Type
3.Date Time
4.Development
5.Document
6.Dojo toolkit
7.Event
8.Event onMethod
9.Ext JS
10.Form Control
11.GUI Components
12.HTML
13.Javascript Collections
14.Javascript Objects
15.Javascript Properties
16.jQuery
17.Language Basics
18.Mochkit
19.Mootools
20.Node Operation
21.Object Oriented
22.Page Components
23.Rico
24.Scriptaculous
25.Security
26.SmartClient
27.Style Layout
28.Table
29.Utilities
30.Window Browser
31.YUI Library
JavaScript DHTML » Page Components » Slide Show 
Creating a Slide Show Using a Random Number Generator

/*

Learn How to Program Using Any Web Browser
by Harold Davis 

Apress CopyRight 2004

ISBN: 1590591135
*/
<HTML>
<HEAD>
<TITLE>Slide Show</TITLE>
</HEAD>
<BODY bgcolor=black text=white>
<SCRIPT
var gardenPix = new Array 
("","http://www.bearhome.com/garden/images/gard1.jpg"
"http://www.bearhome.com/garden/images/gard2.jpg"
"http://www.bearhome.com/garden/images/gard3.jpg"
"http://www.bearhome.com/garden/images/gard4.jpg"
"http://www.bearhome.com/garden/images/gard5.jpg"
"http://www.bearhome.com/garden/images/gard6.jpg"
"http://www.bearhome.com/garden/images/gard7.jpg"
"http://www.bearhome.com/garden/images/gard8.jpg"
"http://www.bearhome.com/garden/images/gard9.jpg"
"http://www.bearhome.com/garden/images/gard10.jpg")
var whichPic = 1
var timeOutId; 
function inOrder() { 
   showPic(whichPic)
   whichPic ++; 
   if (whichPic > 10
      whichPic = 1
   status = whichPic; 
   timeOutId=setTimeout("inOrder();",1000)

function showRandom() { 
   whichPic = Math.floor(Math.random() 11)
   if (whichPic == 0
      whichPic = 1
   showPic(whichPic)
   status = whichPic; 
   timeOutId=setTimeout("showRandom();",1000)

function showPic(i) { 
   document.images[0].src=gardenPix[i]

// End code hiding from ancient browsers -->
</SCRIPT>
<H1>View a slide show of our garden today!</H1>
<FORM>
<TABLE cellpadding=20 cellspacing=2 0>
<TR>
<TD>
<INPUT type=button value="Show in Order" name=theButton 
onClick="inOrder();">
</TD>
<TD>
<INPUT type=button value="Random and Repeat" 
name=theButton onClick="showRandom();">
</TD>
<TD>
<INPUT type=button value="Stop" name=theButton 
onClick="clearTimeout(timeOutId);">
</TD>
</TR>
</TABLE>
<BR>
</FORM>
<IMG name=slideshow src="http://www.bearhome.com/garden/images/gard6.jpg" 
   width=500 border=5>
</BODY>
</HTML>
           
       
Related examples in the same category
1.Slide Show: Mixed Slides, Next Slide, Previous Slide
2.Animal Kingdom Slideshow
3.DHTML Slide Show
4.slide show Demo
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.