473,714 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with JavaScript code Please

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, Previous Slide and Home Slide.

Is it possible for you to view my page and tell me what I am doing
wrong. I have looked at this page for hours and can't figure it out, I
must be missing something or have something in the wrong order, but
can't figure it out...please help....thanks. ..

I think I need someone to explain the EXACT code for this page as it
would appear in the page so it displays correctly.

If you can figure this out, I have 2 more I need help with too...

Thanks so much, Much appreciated...N eed a quick answer that will work!

Any ideas???? Can someone please tell me what I'm doing wrong, or what
I have missed out....

Here is my code:
<HTML>
<HEAD>
<TITLE>JavaScri pt Slide Show - PhotoAlbum</TITLE>

<SCRIPT LANGUAGE="JavaS cript">

var PhotoAlbum = new
Array("bunny_la dy.gif","busine ss_lady.gif","r unning_lady.gif ","color_lady.g if")
var PicIndex=1
var pictures=PhotoA lbum.length

function NextImage ( ) {
if (PicIndex < pictures) {
PicIndex++
}
document.ImgAlb um.src=PhotoAlb um[PicIndex-1]
}

function PreviousImage ( ) {
if (PicIndex > 1) {
PicIndex--
}
document.ImgAlb um.src=PhotoAlb um[PicIndex-1]
}

function home ( ) {
document.ImgAlb um.src=PhotoAlb um[0]
}
</SCRIPT>
</HEAD>

<BODY BACKGROUND=BACK 02.jpg TEXT=Blue>

<CENTER>

<H1 ALIGN=Center> The Vacation Photo Album</H1><BR>
<H3 ALIGN=Center> Click on Previous or Next to view pictures in my
Slide Show </H3><HR><HR>

<IMG SRC=bunny_purse .gif NAME= ImgAlbum Width=400 Height=270>
<BR>
<HR>
<A HREF="JavaScrip t:home ( ) ">[First Image]</A>
<A HREF="JavaScrip t:PreviousImage ( )">[Previous Image]</A>
<A HREF="JavaScrip t:NextImage ( )">[Next Image]</A>
</CENTER>

</BODY>
</HTML>
Jul 23 '05 #1
5 2059
TrvlOrm wrote:
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, Previous Slide and Home Slide.

Is it possible for you to view my page and tell me what I am doing
wrong. I have looked at this page for hours and can't figure it out, I
must be missing something or have something in the wrong order, but
can't figure it out...please help....thanks. ..

I think I need someone to explain the EXACT code for this page as it
would appear in the page so it displays correctly.

If you can figure this out, I have 2 more I need help with too...

Thanks so much, Much appreciated...N eed a quick answer that will work!

Any ideas???? Can someone please tell me what I'm doing wrong, or what
I have missed out....

Here is my code:
<HTML>
<HEAD>
<TITLE>JavaScri pt Slide Show - PhotoAlbum</TITLE>

<SCRIPT LANGUAGE="JavaS cript">

var PhotoAlbum = new
Array("bunny_la dy.gif","busine ss_lady.gif","r unning_lady.gif ","color_lady.g if")
var PicIndex=1
var pictures=PhotoA lbum.length

function NextImage ( ) {
if (PicIndex < pictures) {
PicIndex++
}
document.ImgAlb um.src=PhotoAlb um[PicIndex-1]
}

function PreviousImage ( ) {
if (PicIndex > 1) {
PicIndex--
}
document.ImgAlb um.src=PhotoAlb um[PicIndex-1]
}

function home ( ) {
document.ImgAlb um.src=PhotoAlb um[0]
}
</SCRIPT>
</HEAD>

<BODY BACKGROUND=BACK 02.jpg TEXT=Blue>

<CENTER>

<H1 ALIGN=Center> The Vacation Photo Album</H1><BR>
<H3 ALIGN=Center> Click on Previous or Next to view pictures in my
Slide Show </H3><HR><HR>

<IMG SRC=bunny_purse .gif NAME= ImgAlbum Width=400 Height=270>
<BR>
<HR>
<A HREF="JavaScrip t:home ( ) ">[First Image]</A>
<A HREF="JavaScrip t:PreviousImage ( )">[Previous Image]</A>
<A HREF="JavaScrip t:NextImage ( )">[Next Image]</A>
</CENTER>

</BODY>
</HTML>

First your IMG tag change NAME= ImgAlbum to ID="ImageAlbum "

Then change all references of document.ImgAlb um.src to
document.getEle mentById("ImgAl bum").src this will make it compatible
with the more modern versions of netscape/mozilla/firefox.

Those are the obvious problems, check back if it doesn't work.

----------
http://www.hunlock.com -- DHTML for the masses.

Jul 23 '05 #2
pcx99 wrote:
TrvlOrm wrote:
<A HREF="JavaScrip t:home ( ) ">[First Image]</A>
<A HREF="JavaScrip t:PreviousImage ( )">[Previous Image]</A>
<A HREF="JavaScrip t:NextImage ( )">[Next Image]</A>
</CENTER>

</BODY>
</HTML>

http://www.jibbering.com/faq/#FAQ4_24


First your IMG tag change NAME= ImgAlbum to ID="ImageAlbum "

Then change all references of document.ImgAlb um.src to
document.getEle mentById("ImgAl bum").src this will make it compatible
with the more modern versions of netscape/mozilla/firefox.

Those are the obvious problems, check back if it doesn't work.


Change it to document.images['ImgAlbum'].src and it is both forwards
*and* backwards compatible. gEBI is not.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Jul 23 '05 #3
On Wed, 05 May 2004 08:11:40 GMT, pcx99 <x@x.com> wrote:

[snip]
<HTML>
<HEAD>
<TITLE>JavaScri pt Slide Show - PhotoAlbum</TITLE>

<SCRIPT LANGUAGE="JavaS cript">

This should read

<script type="text/javascript">

The type attribute is required whereas the language attribute is
deprecated and should not be used.

[snipped HTML]

Have a play with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<title>Slidesho w</title>

<!-- The days of presentational mark-up are over. Use style sheets. -->
<style type="text/css">
body {
text-align: center;
}

button {
margin: 0 2px;
}

div#imgContaine r {
border-bottom: 2px solid #000000;
border-top: 5px double #000000;
padding: 2px 0;
}

div#navigation {
margin-top: 5px;
}
</style>

<script type="text/javascript">
var current = 0;
var album = [
"bunny_lady.gif ",
"business_lady. gif",
"running_lady.g if",
"color_lady.gif " ];

function nextImg() {
if( album.length == ++current ) {
current = 0;
}
showImg( current );
}

function prevImg() {
if( 0 > --current ) {
current = album.length - 1;
}
showImg( current );
}

function showImg( n ) {
document.images[ 'albumImg' ].src = album[ n ];
}
</script>
</head>

<body>
<!-- If you don't like the size of the text, don't change the heading
types,
change the text size. It's bad form to skip heading levels just for
aesthetic reasons -->
<h1>The Vacation Photo Album</h1>
<h2>Click on Previous or Next to view pictures in my Slide Show</h2>
<div id="imgContaine r">
<img id="albumImg" alt="Photo" src="bunny_purs e.gif" width="400"
height="270">
</div>
<div id="navigation" >
<!-- If you do want to use text instead of buttons, don't use the
JavaScript URI scheme (javascript:).
See <URL:http://jibbering.com/faq/#FAQ4_24> -->
<button type="button" onclick="prevIm g()">Previous</button>
<button type="button" onclick="showIm g(0)">Home</button>
<button type="button" onclick="nextIm g()">Next</button>
</div>
</body>
</html>
First your IMG tag change NAME= ImgAlbum to ID="ImageAlbum "

Then change all references of document.ImgAlb um.src to
document.getEle mentById("ImgAl bum").src this will make it compatible
with the more modern versions of netscape/mozilla/firefox.


The more sensible thing to do is use the images collection as this will
work in even the early Netscape browsers. You can index it with indicies
or a string that contains the name or id of the image.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #4
Mike, your code doesn't seem to work. I have imputted it in exactly as
you have, but the Previos and Next Images do not load...just comes
back saying error on page...
(JavaScript SlideShow)

What else have we missed out?

Thanks again....

<HTML>
<HEAD>

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<TITLE>Exerci se 8-3 JavaScript Slide Show - Discussion Forum
HELP</TITLE>

<STYLE TYPE="text/css">

BODY {
text=align: center;
}

Button {
margin: 0 2px;
}

div#imgContaine r {
boder-bottom: 2px solid #000000;
boder-top: 5px double #000000;
padding: 2px 0;
}

div#navigation {
margin-top: 5px;
}
</STYLE>

<SCRIPT TYPE="text/javascript">
var current = 0;
var Imagealbum = [
"bunny_lady.gif ",
"business_lady. gif",
"running_lady.g if",
"color_lady.gif "];

function nextImage();
if( album.length = +current ) {
current = 0;
}
showImage( current );
}

function prevImage() {
if( 0 > -current ) {
current = album.length - 1;
}
showImage( current );
}

function showImage( n ) {
document.images['Imagealbum'].src = alubum[ n ];
}
</SCRIPT>
</HEAD>

<BODY>

<H1> The Vacation Photo Album</H1>
<H2> Click on Previous or Next to view pictures in my Slide Show </H2>

<div id ="imageContaine r">

<image id="Imagealbum " alt="Photo" src="bunny_purs e.gif" width="400"
Height="270">
</div>

<div id="navigation" >
<button type="button" onclick="prevIm age()">Previous image</button>
<button type="button" onclick="showIm age()">Home</button>
<button type="button" onclick="nextIm age()">Next image</button>

</div>

</BODY>
</HTML>
Jul 23 '05 #5
On 5 May 2004 12:51:50 -0700, TrvlOrm <ks*****@shaw.c a> wrote:
Mike, your code doesn't seem to work.
I can assure you it does. If you changed the BUTTONs to INPUTs of type
button, it would even work on NN4[1].
I have imputted it in exactly as you have, [...]


No, you didn't. Even a cursory glance shows several instances where you
changed the name of some, but not all, occurances of an identifier. Rather
than typing it, which is what you appeared to do, copy and paste the HTML
verbatim then modify it. Don't forget to include the DTD (<!DOCTYPE ...).

[snipped HTML]

Mike
[1] I always wondered why some people persisted in using INPUT elements
for button, submit and reset controls, rather than the more versatile
BUTTON element. Support for the NN4 generation of browsers must be the
reason.

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #6

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

Similar topics

8
4230
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link, which when you click it bookmarks the site (much easier). The favicon is never saved if the site is bookmarked this way. Does anyone have any ideas how to fix this?? This is the code: <script language="JavaScript">
8
2030
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to get the focus no matter where on the page the user clicks be it right-click or left-click. Right now there is no context menu when the user right-clicks. Do you think that's the problem? Any ideas how to get this right-click left-click Input box...
1
6090
by: bin_P19 P | last post by:
the code i have got is as follows and now im stuck <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping Cart</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="StyleSheet" href="css/style.css" type="text/css">
5
2291
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action to either a) generate numbers b) Prompts a user to locate a web page c) go to previous page in history list d) Loads next page in history list e) Promps the user for a URL and loads the web page in a new window f) and Re-Sizes the window. ...
4
2002
by: Adrienne | last post by:
I am the first to admit that I know bupkis about javascript, except that sometimes I need it to do something client side that I can't do server side. Anyway, here's my problem: <input type="text" name="ticket" id="ticket"> <input type="text" name="amount" id="amount"> My ASP script defaults ticket to be 30.00 and amount to be 600.00. What
18
3035
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How ??
22
2330
by: the_grove_man | last post by:
I purchased a book titled "Pro ASP.NET 2.0" to get up to speed on web stuff because I ususally do Windows Form Applications.. But in the first chapters I was reading this week it brought to mind some things I heard in the past that I thought someone could clarify. On Page 6 it states "ASP.NET web pages (and web services) are executed within the CLR (common language runtime), so they can be authored in any language that has a...
10
2754
by: sufian | last post by:
I am new to the world of PHP. Below is my simple PHP file "invite.php" with a form having an image send button (I have to use the image send button because it is the requirement, may be this is causing problem!): <html> <head><title>Form</title> </head> <body> <script language="javascript" src="validation.js"></script> <form action="submit.php" method="POST"> <table border ="0" align="center" cellpadding="9"...
2
3153
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
0
8801
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8707
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9314
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9015
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7953
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4464
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2520
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2110
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.