473,386 Members | 1,745 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,386 software developers and data experts.

Script Is Almost There

I was really proud of myself. Having never worked with javascript before I
took two scripts - one that did a slideshow but fit the image to the table
and one that did not but provided a caption and I managed to get them
together.

Unfortauntely the "Previous" link returns an "undefined" error the second
time through it. Does anyone have an idea what I might have done wrong??

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<script>
var NewImg = new Array(); // don't change this
var Caption = new Array(); // don't change this

NewImg[7] = 'pic1.jpeg';
NewImg[2] = 'pic2.jpeg';
NewImg[3] = 'pic3.jpeg';
NewImg[4] = 'pic4.jpeg';
NewImg[5] = 'pic5.jpeg';
NewImg[6] = 'pic6.jpeg';
NewImg[1] = 'pic7.jpeg';
NewImg[8] = 'newlogo.jpg';

// Specify the Captions...
// To add more captions, just continue
// the pattern, adding to the array below.
// To use fewer captions, remove lines
// starting at the end of the Caption array.
// Caution: The number of Captions *must*
// equal the number of NewImgs!

Caption[1] = "Text for picture1.";
Caption[2] = "Text for picture2.";
Caption[3] = "Text for picture3.";
Caption[4] = "Text for picture4.";
Caption[5] = "Text for picture5.";
Caption[6] = "Text for picture6.";
Caption[7] = "Text for picture7.";
Caption[8] = "Text for picture8.";
var ImgNum = 0;
var ImgLength = NewImg.length - 1;
var ImgCap = Caption.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;
ImgCap = ImgCap + direction;
if (ImgNum > ImgLength) {
ImgNum = 1;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg[ImgNum];
}
if (document.getElementById)
document.getElementById("CaptionBox").innerHTML= Caption[ImgNum];

}
function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}}
// End -->
</script>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<body onload='showHot=true;self.focus();'">

<table border="1" id="table1 " width="30%">
<tr>
<td id=CaptionBox class=Caption align=center colspan="3">
Welcome to Sand Bay Beach Resorts!!<br>Designed By
<a href="http://www.kjmsolutions.com ">KJM Solutions</a></td>
</td>
</tr>

<td colspan="3"><!--webbot bot="HTMLMarkup " startspan --><img
src="http://newlogo.jpg " name="slideshow"> //this line causes error on
slideshow but //putting a space after the w and before the " seemed to make
it go away. I know dumb idea right :)?
<tr/>
<td width="50 "><a href="javascript:chgImg(1) ">Next</a></td>

<td width = "50 "><a href="javascript:chgImg(-1) ">Previous</a></td>

<td width = "50 "><a href="javascript:auto() ">Auto/Stop</a></td>

</tr>

</table>
<!--webbot bot="HTMLMarkup " endspan i-checksum="26346" --></td>
</tr>
</table>

<p>&nbsp;</p>

</body>

</html>
Jul 23 '05 #1
7 1263
Welcome to the wild world of JavaScript, Scorpion 53061!
NewImg[7] = 'pic1.jpeg';
NewImg[2] = 'pic2.jpeg';
NewImg[3] = 'pic3.jpeg';
NewImg[4] = 'pic4.jpeg';
NewImg[5] = 'pic5.jpeg';
NewImg[6] = 'pic6.jpeg';
NewImg[1] = 'pic7.jpeg';
NewImg[8] = 'newlogo.jpg';
Did you know that this can be replaced by:

NewImg = [
'pic7.jpeg',
'pic2.jpeg',
'pic3.jpeg',
'pic4.jpeg',
'pic5.jpeg',
'pic6.jpeg',
'pic1.jpeg',
'newlogo.jpg'
];

Saves some typing (and precious bandwidth).
Unfortauntely the "Previous" link returns an "undefined" error the second
time through it. Does anyone have an idea what I might have done wrong??


I'll leave the debugging to others; however, I will point out that
your HTML is invalid. Fix it, then put your script into an external
file (for maximum efficiency).

Here's a hint, though. You probably have a "race condition" causing
the error. Type wrapping everything into a function, and call it
during the onload event.

Hope that's useful,

--
Jimmy Cerra
Jul 23 '05 #2
Thanks Jimmy...

This page is at

http://www.sandbaybeachresort.com/as...dardsuites.asp

Everything is working perfectly now except that the bottom "include page"
(called "bottom.htm") disappeared after applying the script although it is
visible in Frontpage.

Can you or anyone help please....
"Jimmy Cerra" <ji*******@hotmail.com> wrote in message
news:94**************************@posting.google.c om...
Welcome to the wild world of JavaScript, Scorpion 53061!
NewImg[7] = 'pic1.jpeg';
NewImg[2] = 'pic2.jpeg';
NewImg[3] = 'pic3.jpeg';
NewImg[4] = 'pic4.jpeg';
NewImg[5] = 'pic5.jpeg';
NewImg[6] = 'pic6.jpeg';
NewImg[1] = 'pic7.jpeg';
NewImg[8] = 'newlogo.jpg';


Did you know that this can be replaced by:

NewImg = [
'pic7.jpeg',
'pic2.jpeg',
'pic3.jpeg',
'pic4.jpeg',
'pic5.jpeg',
'pic6.jpeg',
'pic1.jpeg',
'newlogo.jpg'
];

Saves some typing (and precious bandwidth).
Unfortauntely the "Previous" link returns an "undefined" error the second time through it. Does anyone have an idea what I might have done wrong??


I'll leave the debugging to others; however, I will point out that
your HTML is invalid. Fix it, then put your script into an external
file (for maximum efficiency).

Here's a hint, though. You probably have a "race condition" causing
the error. Type wrapping everything into a function, and call it
during the onload event.

Hope that's useful,

--
Jimmy Cerra

Jul 23 '05 #3
Problem solved thanks Jimmy.
"Jimmy Cerra" <ji*******@hotmail.com> wrote in message
news:94**************************@posting.google.c om...
Welcome to the wild world of JavaScript, Scorpion 53061!
NewImg[7] = 'pic1.jpeg';
NewImg[2] = 'pic2.jpeg';
NewImg[3] = 'pic3.jpeg';
NewImg[4] = 'pic4.jpeg';
NewImg[5] = 'pic5.jpeg';
NewImg[6] = 'pic6.jpeg';
NewImg[1] = 'pic7.jpeg';
NewImg[8] = 'newlogo.jpg';


Did you know that this can be replaced by:

NewImg = [
'pic7.jpeg',
'pic2.jpeg',
'pic3.jpeg',
'pic4.jpeg',
'pic5.jpeg',
'pic6.jpeg',
'pic1.jpeg',
'newlogo.jpg'
];

Saves some typing (and precious bandwidth).
Unfortauntely the "Previous" link returns an "undefined" error the second time through it. Does anyone have an idea what I might have done wrong??


I'll leave the debugging to others; however, I will point out that
your HTML is invalid. Fix it, then put your script into an external
file (for maximum efficiency).

Here's a hint, though. You probably have a "race condition" causing
the error. Type wrapping everything into a function, and call it
during the onload event.

Hope that's useful,

--
Jimmy Cerra

Jul 23 '05 #4
scorpion53061 wrote:
This page is at

http://www.sandbaybeachresort.com/as...dardsuites.asp

Everything is working perfectly now [...]
No, see
<http://validator.w3.org/check?uri=http://www.sandbaybeachresort.com/aspnet_client/sandbaybeach/standardsuites.asp&ss=1;verbose=1>

If I change the encoding to ISO-8859-1 so that the document can be
validated, the Validator shows a bunch of errors you have *not* fixed.
[...]


And if you would have not top-posted as strongly recommended in the
FAQ, you would have probably known: <http://jibbering.com/faq/#FAQ2_3>
PointedEars
Jul 23 '05 #5
Thanks Thomas what exact purpose does your posting serve other than to tear
those down around you. I stated I was new at this. I suppose you were born
with all the wisdom that javascript has to give right?

And I will post any way I want thank you very much.
"Thomas 'PointedEars' Lahn" <Po*********@nurfuerspam.de> wrote in message
news:40**************@PointedEars.de...
scorpion53061 wrote:
This page is at

http://www.sandbaybeachresort.com/as...dardsuites.asp
Everything is working perfectly now [...]
No, see

<http://validator.w3.org/check?uri=ht...rt.com/aspnet_
client/sandbaybeach/standardsuites.asp&ss=1;verbose=1>
If I change the encoding to ISO-8859-1 so that the document can be
validated, the Validator shows a bunch of errors you have *not* fixed.
[...]


And if you would have not top-posted as strongly recommended in the
FAQ, you would have probably known: <http://jibbering.com/faq/#FAQ2_3>
PointedEars

Jul 23 '05 #6
On Mon, 19 Jul 2004 22:39:11 -0500, scorpion53061 wrote:
Thanks Thomas what exact purpose does your posting serve other than to tear
those down around you.


Thomas made good points. You cannot expect JS
to work as you expect if the underlying HTML
structure is broken.

Fix the HTML first, ensure the (any) CSS
is valid, *then* look at the JS.

And in relation to the 'top-post' comment.

It can be rather frustrating if long, detailed
answers are provided (does not really apply here)
yet it becomes apparent the OP only read the
first few lines of the response.

My advice to you. Do not be sensitive or precious.

You can gain quite a lot from these forums if you
can learn to tolerate a bit of 'rough and tumble'.
Whereas if you're a sensitive type, you tend not
to see through the criticism (perceived or actual)
to the golden nugget of advice at the center.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #7
I am just in a bad mood.

And that didnt help.

I said in my post I was new at this. I am trying, and it is frustrating at
times.

Thanks for your thoughts.

"Andrew Thompson" <Se********@www.invalid> wrote in message
news:if*****************************@40tude.net...
On Mon, 19 Jul 2004 22:39:11 -0500, scorpion53061 wrote:
Thanks Thomas what exact purpose does your posting serve other than to tear those down around you.


Thomas made good points. You cannot expect JS
to work as you expect if the underlying HTML
structure is broken.

Fix the HTML first, ensure the (any) CSS
is valid, *then* look at the JS.

And in relation to the 'top-post' comment.

It can be rather frustrating if long, detailed
answers are provided (does not really apply here)
yet it becomes apparent the OP only read the
first few lines of the response.

My advice to you. Do not be sensitive or precious.

You can gain quite a lot from these forums if you
can learn to tolerate a bit of 'rough and tumble'.
Whereas if you're a sensitive type, you tend not
to see through the criticism (perceived or actual)
to the golden nugget of advice at the center.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Jul 23 '05 #8

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

Similar topics

8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
5
by: jkarp2 | last post by:
Ok. Here's the problem: I am making a website, and want to be able to update news without having to go through the hassle of changing the page in Dreamweaver and uploading it via FTP. So I...
2
by: Christopher | last post by:
I am looking to learn vb script to interface with a program that already exists. Does there exist documentation for Vb script like there is for c++? For example using vc6.0 I can look up almost any...
1
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast,...
11
by: Wentink | last post by:
Does anybody have a simple script that let's me popup a picture from a thumbnail? The ones i found are all very very complicated and messy in the source... Thanks, Tintin
16
by: Luca | last post by:
About one month ago I have inserted in my web site a clickcounter who controls the access to almost every link, but this script who changed the path in every link so the search engines couldn't...
6
by: VK | last post by:
I'm using window.open method in my script to open poup window. Recently Internet Explorer users reported that the script crashes on their machine with different runtime errors. See the bug:...
10
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all...
24
by: Peter Michaux | last post by:
I have a Perl script that I want to run as a set-user-ID program. Many OSes don't allow scripts run as set-user-ID. To make this script portable, it seems I need to write a C wrapper program that...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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
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...

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.