Hi guys
I've been using this, my favorite slideshow script for its simplicity. Now I'd like to add a text caption to each image that rotates in-kind, but I'm having trouble working out the dynamics.
Here's the current script:
<SCRIPT LANGUAGE="JAVAS CRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
myPix = new Array(
"images/picture01.jpg",
"images/picture02.jpg",
"images/picture03.jpg",
"images/picture04.jpg")
thisPic = 0
imgCt = myPix.length - 1
function chgSlide(direct ion) {
if (document.image s) {
thisPic = thisPic + direction
if (thisPic > imgCt) {
thisPic = 0
}
if (thisPic < 0) {
thisPic = imgCt
}
document.myPict ure.src=myPix[thisPic]
}
}
// -->
</SCRIPT>
<P><IMG SRC="images/picture01.jpg" NAME="myPicture " WIDTH="300" HEIGHT="200"></P>
<A HREF="javascrip t:chgSlide(-1)"><< Back</A> <A HREF="javascrip t:chgSlide(1)"> Forward >></A>
I was thinking that I could add this second array, but am stuck on how to integrate the resulting variable into the body:
myCap = new Array(
"Text Caption 01",
"Text Caption 02",
"Text Caption 03",
"Text Caption 04")
thisCap = 0
imgCt = myCap.length - 1
function chgSlide(direct ion) {
if (document.image s) {
thisCap = thisCap + direction
if (thisCap > imgCt) {
thisCap = 0
}
if (thisCap < 0) {
thisCap = imgCt
}
document.myCapt ion.src=myCap[thisCap]
}
}
Any ideas?
4 3055
I found a simple way to use a textarea tag, but it looks junky.
<TEXTAREA NAME=myCaption> </TEXTAREA>
I'd like for the text to appear as if it was simple HTML text.
I tried combining the variables to no avail, but I think I'm getting closer. This variant tells me, however, that 'myCaption' is null, even though I follow the other array's scripting precisely. What am I doing wrong?
<SCRIPT LANGUAGE="JAVAS CRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
myPix = new Array(
"images/01.jpg",
"images/02.jpg",
"images/03.jpg")
thisPic = 0
imgCt = myPix.length - 1
myTxt = new Array(
"Caption 1",
"Caption 2",
"Caption 3")
thisTxt = 0
txtCt = myTxt.length - 1
function chgSlide(direct ion) {
if (document.image s) {
thisPic = thisPic + direction
thisTxt = thisTxt + direction
if (thisPic > imgCt) {
thisPic = 0
thisTxt = 0
}
if (thisPic < 0) {
thisPic = imgCt
thisTxt = txtCt
}
document.myPict ure.src=myPix[thisPic]
document.myCapt ion.src=myTxt[thisTxt]
}
}
// -->
</SCRIPT>
<P><IMG SRC="images/01.jpg" NAME="myPicture " WIDTH="50" HEIGHT="40" ALT="Slideshow" ></P>
<SCRIPT LANGUAGE="JAVAS CRIPT" TYPE="TEXT/JAVASCRIPT">
document.write( myCaption)
</SCRIPT><BR>
<A HREF="javascrip t:chgSlide(-1)">Back</A> <A HREF="javascrip t:chgSlide(1)"> Forward</A>
document.myCapt ion.src=myTxt[thisTxt]
You don't have an element called document.myCapt ion so you cant give it a src property, and even if you could it wouldn't be any use.
Create a <span> element with whatever CSS styling you want, give it an ID attribute, say 'myCaption', include the function below and use it thus:
caption('myCapt ion', myTxt[thisTxt]); - function caption(elemId, txt)
-
{
-
var elem;
-
-
if(document.getElementById && (elem=document.getElementById(elemId)))
-
if(elem.firstChild)
-
elem.firstChild.data=txt;
-
else
-
elem.appendChild(document.createTextNode(txt));
-
}
@ADMIN - Why are we now getting those poxy line numbers that nobody wants?
Alternatively, try a different slideshow
Thanks. I'm motivated to use this one because it's very basic - no transition effects, no page refreshing, no fancy text boxes. Just a picture and some text that can be formatted using traditional tags. Will give your corrections a whirl - and thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steven Choo |
last post by:
Hi all,
I have used a script which allows visitors of my personal website to
click on a small image to see an enlarged version in a pop-up. It
would be great if i could add some text within the pop-up, say below
the enlarged image, to give visitors a brief description.
Can anyone help with how I would do this? I'm fairly new to all this
so a detailed explanation would be great!
|
by: Amir Hardon |
last post by:
I'm new to DOM and can't figure out this thing:
I'm trying to add a row to a table with a form field in one
of it's cells, but if I'm appending the field to a form
it gets out of the table. Can some one tell me what I'm doing wrong?
it looks like this:
var tbl=document.tbl;
var frm=document.frm;
var newcell=document.createElement("TD");
|
by: ziggy.696040 |
last post by:
My web page has thumbnail pictures, and when the user clicks on a
thumbnail, I change the image source of a full-size image elsewhere on
the page. I'd also like to change the caption of the full-size image,
but I'm not sure how to set the value of the text. I've tried creating
a form with a single input field, and I can set the value of that
field, but the field has a sunken style that I can't get rid of, and
I'd like to find a different...
|
by: Chenghui Li |
last post by:
We have a problem with the Windows XP theme:
We have a IDE which allows other developers to develop visual programs for their customers.
Our IDE allow them to set font for window captions easyly (through a dialog). It works fine fo
W98, 2000, NT, and XP is the theme is Classic. But on XP if the theme is "Windows XP", the
we have a problem: if the developer set the caption font to be say, "Script" (and all non-default
font), then the...
|
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'
to large numbers and small numbers but it doesn't seem to do anything. Could
someone explain what effect changing this variable should bring about and
why don't I see any changes.
many thanks
David
| |
by: Casey Miller |
last post by:
I have a site, http://www.onemorewebsite.com, that has a menu on the left
side and a picture on the right side with a middle div for content in the
middle. When I mouse over the menu, the picture changes. I've got that part
to work. But I also want the text caption under the picture to change also.
I can't figure this one out. I've spent days learning about innerHTML,
textnodes, etc..but nothing works. Can anyone give me a clue? I'd sure...
|
by: GabrielESandoval |
last post by:
i currently use the code below to create a slideshow of images. i
edited it so that its not as long. i currently have over 20 images
i want to change it so that the images dont appear in the same order
each time. what would i have to change to make the cycle random???
thanks in advance for the help.
gabriel
-- heres the code --
|
by: mrtaka79 |
last post by:
Okay, first of all, I'm a complete noob, so go easy on me. I have this
code that works perfectly for me. The only thing I want to add is to
randomize the pictures/links that show up. Can anyone just tell me
where to add additional code to the following? BTW this is the only
code I could find that works in my Beta Blogger sidebar.
<a href="javascript:gotoshow()"><img border="0" width="300"
src="/OneMissedCall1.jpg" name="slide"...
|
by: littlealex |
last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS!
In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly?
http://geekarama.co.uk/new_home.html
here is the code for new_home.html and following that the CSS...
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |