473,402 Members | 2,050 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,402 software developers and data experts.

slideshow and variable name for images (global?)

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 images of
the thumbnails. When the slideshow begins it always starts with the
first image. I would like to pass the name of the thumbnail to the
slideshow HTML page and begin the slideshow with the same image the
user clicks on. Is this asking too much? Does anyone have a solution?
-----------------------------------------------------------------
---------thumbnail page
-----------------------------------------------------------------
-----------------------------------------------------------------
-----------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>DHS Homecoming 2005</title>
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1">
<link rel=stylesheet type="text/css" href="styles.css">
</head>

<body>
<h1 class=title>Homecoming 2005</h1>

<p class=desc>Munson Stadium, Forest Park - September 23,
2005<br><br>Click on any photo to see an enlarged version.
</p>

<br>

<center>
<table cellspacing="12">
<tr>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0021"><img
src="thumbs/DSC00067.jpg" width="192" height="131" border="0"
alt="DSC00067.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0018"><img
src="thumbs/DSC00068.jpg" width="192" height="131" border="0"
alt="DSC00068.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0020"><img
src="thumbs/DSC00069.jpg" width="192" height="131" border="0"
alt="DSC00069.jpg"></a>
</td>
</tr>
<tr>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0022"><img
src="thumbs/DSC00070.jpg" width="192" height="131" border="0"
alt="DSC00070.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0029"><img
src="thumbs/DSC00071.jpg" width="192" height="131" border="0"
alt="DSC00071.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0030"><img
src="thumbs/DSC00072.jpg" width="192" height="131" border="0"
alt="DSC00072.jpg"></a>
</td>
</tr>
<tr>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0031"><img
src="thumbs/DSC00073.jpg" width="192" height="131" border="0"
alt="DSC00073.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0033"><img
src="thumbs/DSC00074.jpg" width="192" height="131" border="0"
alt="DSC00074.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0035"><img
src="thumbs/DSC00075.jpg" width="192" height="131" border="0"
alt="DSC00075.jpg"></a>
</td>
</tr>
<tr>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0038"><img
src="thumbs/DSC00076.jpg" width="192" height="131" border="0"
alt="DSC00076.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0039"><img
src="thumbs/DSC00077.jpg" width="192" height="131" border="0"
alt="DSC00077.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0040"><img
src="thumbs/DSC00078.jpg" width="192" height="131" border="0"
alt="DSC00078.jpg"></a>
</td>
</tr>
<tr>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0041"><img
src="thumbs/DSC00079.jpg" width="192" height="131" border="0"
alt="DSC00079.jpg"></a>
</td>
<td class=thumbnail width="192" height="192">
<a href="pictures/slides.html" name="dsc_0046"><img
src="thumbs/DSC00080.jpg" width="192" height="131" border="0"
alt="DSC00080.jpg"></a>
</td>

</tr>
</table>
</center>

<br>
<br>
<table cellspacing="8">
<tr>
<td width="20" height="20"> </td>
</tr>
</table>
<p class=desc>Last updated: 6/10/2005
</p>

</body>
</html>
-----------------------------------------------------------------
----------slideshow page
-----------------------------------------------------------------
-----------------------------------------------------------------
-----------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>SOSU Marching Contest</title> <script language="JavaScript">

<!-- Begin
NewImg = new Array (
"DSC00081.jpg",
"DSC00082.jpg",
"DSC00083.jpg",
"DSC00084.jpg",
"DSC00085.jpg",
"DSC00086.jpg",
"DSC00087.jpg",
"DSC00088.jpg",
"DSC00089.jpg",
"DSC00090.jpg",
"DSC00091.jpg",
"DSC00092.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;
var delay = 3000;

var lock = false;
var run;
function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg[ImgNum];
}
}
function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}
}
</script>
<link rel="stylesheet" type="text/css" href="../styles.css">
</head>
<body>
<img src="DSC00081.jpg" name="slideshow" width="850">
<table border="10" frame="box" width="850" bgcolor="#FFCC33">
<tr>
<td align="center" width="100">
<a href="javascript:chgImg(-1)">Previous</a>
</td>
<td align="center">
<a href="javascript:auto()">Auto/Stop</a>
</td>
<td align="center" width="100">
<a href="javascript:chgImg(1)">Next</a>
</td>
</tr>
</table>
</body>
</html>

Sep 25 '05 #1
8 2004
ASM
dr*********@yahoo.com a écrit :
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 images of
the thumbnails. When the slideshow begins it always starts with the
first image. I would like to pass the name of the thumbnail to the
slideshow HTML page and begin the slideshow with the same image the
user clicks on. Is this asking too much? Does anyone have a solution?


I'll expect functions of slideshow work

----slideshow page----

[JS part]

funcion getImg() {
newImg = self.location.search.substring(1)
auto(newImg);
}

function auto(nbrImg) {
nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg("+nbrImg+")", delay);
}
}

[HTML part]

<body onload="getImg()">

----end complement slideshow----

-----thumbnail page-----

links this way :

<a href="pictures/slides.html?67" name="dsc_0021"><img
src="thumbs/DSC00067.jpg" width="192" height="131" border="0"
alt="thumbnail" title="click me to get me in a slideshow"></a>

add number of image to load at end of href
don't forget the '?'
href="file.htm?number"

--
Stephane Moriaux et son [moins] vieux Mac
Sep 25 '05 #2
I added the function "getImg" to the slideshow page and replaced the
function "auto" with your script. I also replaced the "body" tag.

I changed my link on the thumbnail page and made sure I kept the '?'.

When I tried the code, a click on the second picture link (using '?68')
it performed as if nothing had changed. The link still opens the first
picture in the slideshow.

Should the '?' variable be 'DSC00068.jpg'? I tried that also and
nothing changed.

Sep 25 '05 #3
ASM
dr*********@yahoo.com a écrit :
I added the function "getImg" to the slideshow page and replaced the
function "auto" with your script. I also replaced the "body" tag.

I changed my link on the thumbnail page and made sure I kept the '?'.

When I tried the code, a click on the second picture link (using '?68')
it performed as if nothing had changed. The link still opens the first
picture in the slideshow.

Should the '?' variable be 'DSC00068.jpg'? I tried that also and
nothing changed.

an error in a function ?
(a '?' forgoten)

try this :

function auto(nbrImg) {
nbrImg = (nbrImg && nbrImg!='')? nbrImg : 1;
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg("+nbrImg+")", delay);
}
}

--
Stephane Moriaux et son [moins] vieux Mac
Sep 25 '05 #4
ASM
dr*********@yahoo.com a écrit :
I added the function "getImg" to the slideshow page and replaced the
function "auto" with your script. I also replaced the "body" tag.

I changed my link on the thumbnail page and made sure I kept the '?'.

When I tried the code, a click on the second picture link (using '?68')
68 have to be the index of array corresponding
to photo to start with

that's to say i.e. "DSC00085.jpg" in your example :
link -> href="pictures/slides.html?4"
it performed as if nothing had changed. The link still opens the first
picture in the slideshow.

Should the '?' variable be 'DSC00068.jpg'? I tried that also and
nothing changed.


sorry, some misunderstanding with your original script
hope this time it will be ok

----slideshow page----

[JS part]

// new function to start on correct image
funcion getImg() {
ImgNum = self.location.search.substring(1);
// alert to verify if that's ok (to delete after tests)
alert('image number : '+ImgNum);
lock == false;
chgImg(1);
auto();
}

// re-insert old function auto()
// and of course all complete old script you did have
function auto() {
nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}
}

<body onload="getImg();">

----- end ----

if that runs only after some delay
you can try without the onload in body tag
and puting in all end of page (before </body>)
the following :

<script type="text/javascript">
getImg();
</script>
====== variante ======

if you prefer a link this way :
(real photo number)

<a href="pictures/slides.html?0038" name="dsc_0038"><img
src="thumbs/DSC00076.jpg" width="192" height="131" border="0"
alt="DSC00076.jpg">

// new function to start on correct image
funcion getImg() {
var startImg = self.location.search.substring(1);
// alert to verify if that's ok (to delete after tests)
alert('image number : '+startImg);
for var(i=0;i<ImgLength;i++)
if(NewImg[i].indexOf(startImg)>0) ImgNum=i;
// alert to verify if that's ok (to delete after tests)
alert('image Array index = '+ImgNum);
lock == false;
chgImg(1);
auto();
}
--
Stephane Moriaux et son [moins] vieux Mac
Sep 25 '05 #5
Well, I'm pretty stupid with Javascript. I placed the new code in the
slideshow page, but I don't see where the function 'getImg' is called.
Can you tell me how to make the call? Below is the revised code for
the slideshow page. Thanks for the help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Homecoming</title> <script language="JavaScript">
<!-- Original: Mike Canonigo (mi**@canonigo.com) -->
<!-- Web Site: http://www.munkeehead.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
NewImg = new Array (
"DSC00067.jpg",
"DSC00068.jpg",
"DSC00069.jpg",
"DSC00070.jpg",
"DSC00071.jpg",
"DSC00072.jpg",
"DSC00073.jpg",
"DSC00074.jpg",
"DSC00075.jpg",
"DSC00076.jpg",
"DSC00077.jpg",
"DSC00078.jpg",
"DSC00079.jpg",
"DSC00080.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;

//Time delay between Slides in milliseconds
var delay = 3000;

var lock = false;
var run;
function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg[ImgNum];
}
}

// new function to start on correct image
function getImg() {
ImgNum = self.location.search.substring(1);
// alert to verify if that's ok (to delete after tests)
alert('image number : '+ImgNum);
lock == false;
chgImg(1);
auto();

}

// re-insert old function auto()
// and of course all complete old script you did have
function auto() {
nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
if (lock == true) {
lock = false;
window.clearInterval(run);
}

else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}

}
</script>
<link rel="stylesheet" type="text/css" href="../styles.css">
</head>
<body onload="getImg();">
<img src="DSC00067.jpg" name="slideshow" width="850">
<table border="10" frame="box" width="850" bgcolor="#FFCC33">
<tr>
<td align="center" width="100">
<a href="javascript:chgImg(-1)">Previous</a>
</td>
<td align="center">
<a href="javascript:auto()">Auto/Stop</a>
</td>
<td align="center" width="100">
<a href="javascript:chgImg(1)">Next</a>
</td>
</tr>
</table>
</body>
</html>

Sep 25 '05 #6
ASM
dr*********@yahoo.com a écrit :
Well, I'm pretty stupid with Javascript. I placed the new code in the
slideshow page, but I don't see where the function 'getImg' is called.
Can you tell me how to make the call? Below is the revised code for
the slideshow page. Thanks for the help.


ok,
with, in other page, links with real photo number
(I don't know if photo number would be 0038 or 0076 ?)

<a href="pictures/slides.html?0038" name="dsc_0038"><img
src="thumbs/DSC00076.jpg" width="192" height="131" border="0"
alt="DSC00076.jpg"></a>

You can also do :
href="pictures/slides.html?DSC00070.jpg"
if you prefer
but take care : sensitive case (a 'D' is not a 'd')

here is your page (tested)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Homecoming</title> <script language="JavaScript">
<!-- Original: Mike Canonigo (mi**@canonigo.com) -->
<!-- Web Site: http://www.munkeehead.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
NewImg = new Array (
"DSC00067.jpg",
"DSC00068.jpg",
"DSC00069.jpg",
"DSC00070.jpg",
"DSC00071.jpg",
"DSC00072.jpg",
"DSC00073.jpg",
"DSC00074.jpg",
"DSC00075.jpg",
"DSC00076.jpg",
"DSC00077.jpg",
"DSC00078.jpg",
"DSC00079.jpg",
"DSC00080.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;

//Time delay between Slides in milliseconds
var delay = 3000;

var lock = false;
var run;

function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.images['slideshow'].src = NewImg[ImgNum];
}
}

function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}
}

function getImg() {
var startImg = self.location.search.substring(1);
for (var i=0;i<ImgLength;i++)
if(NewImg[i].indexOf(startImg)>0) ImgNum = +i-1;
lock == false;
chgImg(1);
auto();
}

</script>
<link rel="stylesheet" type="text/css" href="../styles.css">
<style type="text/css">
p, button { text-align: center; }
img { margin: auto; margin-bottom: 10px; width: 850px; }
p.buttons { background-color: #fc3; margin: 10px; border: 1px solid black; }
button { border: outset goldenrod 3px; background: #ff9;
color: maroon; margin: 4px 10px; width: 100px; }
button:hover { border-style: inset; }
button:active { background: orange; color: white; }
</style>
</head>
<body>
<p><img src="DSC00067.jpg" name="slideshow" width="850"></p>
<p class="buttons">
<button onclick="delay=delay*1.2;auto();auto();">Slower</button>
<button onclick="chgImg(-1)">Previous</button>
<button onclick="auto()">Auto/Stop</button>
<button onclick="chgImg(1)">Next</button>
<button onclick="delay=delay*.8;auto();auto();">Faster</button>
</p>
<script type="text/javascript">
getImg();
</script>
</body>
</html>

--
Stephane Moriaux et son [moins] vieux Mac
Sep 25 '05 #7
ASM wrote:
<snip>
function auto(nbrImg) {
nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg("+nbrImg+")", delay);
}
}

<snip>

What a very bad example of programming. Beyond the omission of the
question mark in the conditional expression, what values for - nbrImg -
are expected to type convert to boolean true and then possibly equal the
empty string? The possible value of - nbrImg - that will producde false
in - nbrImg != '' - are boolean false, +/- zero and the empty string,
all of which either are false or would type-convert to false in the
right hand side of the logical expression.

It is invariable unwise to perform type-converting comparison with a
boolean value without a specific reason. The values that do equal true
with type-converting comparison are: boolean true, the number 1 and the
string "1". It is unusual to want to only allow this particular set of
values to trigger the entry into a branch in an if/else statement. It is
much more likely that the intention is that the - lock - value be
exclusively boolean and so that requirement would be enforced with a
strict comparison operation (===), or taken advantage of by allowing the
internal ToBoolean call implicit in the - if - expression to react to
the true-ness of the value, eliminating the then redundant comparison,
and the - if - statement in the else branch. So either:-

Only when boolean:-

if(lock === true){ //only if boolean true
....
}else if(lock === false){ //else if boolean false
...
}

-or, reacting to type-converted true-ness:-

if(lock){ // any 'true' value including boolean true
...
}else{ //else any 'false' value including boolean false
...
}

If the global - lock - variable is initialised (as it mist be for the
original function to work at all) then it would be logical to initials
it to boolean false, and then use the second if/else formulation where
only boolean values are assigned to - lock -.

Richard.
Sep 25 '05 #8
ASM
Richard Cornford a écrit :
ASM wrote:
<snip>
function auto(nbrImg) {
nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg("+nbrImg+")", delay);
}
}
<snip>

What a very bad example of programming. Beyond the omission of the
question mark in the conditional expression,


I've seen it too late
what values for - nbrImg -
are expected to type convert to boolean true and then possibly equal the
empty string? The possible value of - nbrImg - that will producde false
in - nbrImg != '' - are boolean false, +/- zero and the empty string,
all of which either are false or would type-convert to false in the
right hand side of the logical expression.


I want only to know if nbrImg exists and if is not empty
-> answer waited : false or true
boolean or not is JS's problem.

histories about 'look' are not mine

you forgot to see in thread : <script language="JavaScript">

tell all that to :
<!-- Original: Mike Canonigo (mi**@canonigo.com) -->
<!-- Web Site: http://www.munkeehead.com -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

as I understood this script comes
Certainly a lot of job to correct all oldies and mal writed scripts
is waiting a good soul.

--
Stephane Moriaux et son [moins] vieux Mac
Sep 26 '05 #9

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

Similar topics

4
by: Tim | last post by:
Hope someone in the big wide world can help... What I want to do is have an image slideshow which automatically scrolls through a series of images very fast, then pauses when you move your mouse...
6
by: TonyJeffs | last post by:
I want to create a web-based slideshow where it'll hunt through all the jpg files I put in a folder, irrespective of name or how many, and cycle through them, one by one. This would mean that...
2
by: Susanna | last post by:
Hi all, I'm using the following slideshow script that I found on the web to display changing images with a crossfade effect. Eventually I will be adding many more images to the slideshow. The...
2
by: Jeannie | last post by:
I have a popup window which is a slideshow of about 7 images. When the popup window loads, the first image is present and then the viewer can select next or previous to scroll through the rest of...
2
by: Adrian MacNair | last post by:
Hi I need some help if anyone can understand my crap javascript. The problem is that after the slideshow ends (reaches the end of array) it should stop, but the timeout doesn't clear and I can see...
2
by: jkbarbee37 | last post by:
I've done enough poking around lately to realise that there is a deficiency in Firefox when it comes to using document.images to reference an image for the purpose of building a slideshow. The code...
11
by: David Graham | last post by:
Hi New to javascript. I'm trying to understand how a script at a website I come across works. http://www.BRPPISAFETY.COM Nearly got it but I have changed the variable called 'crossFadeDuration'...
1
by: ttamilvanan81 | last post by:
Hai everyone, I need to provide the slideshow for the images. I have upload the images into database. Then i will retrive all the images from the database and provide the slideshow for those...
2
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...
0
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...

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.