473,732 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multi-image cycling rollover?

I'm having a bit of trouble with this script. I'm wondering if someone might
help me. What I'm trying to do is to have a multiple image rollover whereby
onmouseover, the image's source will cycle through a few pics and stop. I
got this part to work fine--it's the onmouseout part that I'm having some
difficulties with. I would like everything to be included within one
function, instead of two (one for mouseover and one for mouseout). Here is
what I have:

----------------------------------------------------------------------------
--------------------
<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function
KP_multi_img_ro llover(subject, navimg1,navimg2 ,navimg3,navimg 4,navimg5) {
var thesubject = document.getEle mentById(subjec t);
var theimgs = new Array(navimg1,n avimg2,navimg3, navimg4,navimg5 );
var i = 0;
var cycle = setInterval(cyc ler,300);
thesubject.onmo useout = clearInterval(c ycle); setInterval(bac kcycler,300);
function cycler() {
if (i < theimgs.length-1) {
i = i + 1;
thesubject.src = theimgs[i];
}
else {
clearInterval(c ycle);
}
}
function backcycler() {
if (i > 0) {
i = i - 1;
thesubject.src = theimgs[i];
}
else {
clearInterval(b ackcycler);
}
}

}
</script>
</head>
<body>
<img id="item1" src="TH_basemen t-entrance.jpg" width="118" height="90"
onMouseOver="KP _multi_img_roll over('item1','n avpic1.jpg','na vpic2.jpg','nav p
ic3.jpg','navpi c4.jpg','navpic 5.jpg');">
</body>
</html>
----------------------------------------------------------------------------
--------------------

Now, I realize the problem is with the "thesubject.onm ouseout =
clearInterval(c ycle); setInterval(bac kcycler,300);" statement, but I can't
figure out why it isn't working. I thought you could use event handlers as
object properties? Help would be appreciated--thanks.
Jul 20 '05 #1
2 5651
"TheKeith" wrote on 13/11/2003:

<snip>
thesubject.onmo useout = clearInterval(c ycle); setInterval(bac kcycler,300);

When specifying handlers like this, you must use the function name
only. If you include the parentheses, the function is called
immediately. This means that you can't specify parameters. Also, the
setInterval() call above will always be called: the preceeding
semi-colon marks the end of the assignment. You could put all of your
script on the same line and it wouldn't change how it was executed.
The assignment and setInterval() call are two separate statements. To
fix this, define a new nested function:

function myMouseOut()
{
window.clearInt erval( cycle );
backcycle = setInterval( backcycler, 300 );
// You need the timer ID to cancel the interval later!
}

and add these to your main function:

var backcycle = null; // With the declarations
....
thesubject.onmo useout = myMouseOut;

<snip>
function backcycler() {
if (i > 0) {
i = i - 1;
thesubject.src = theimgs[i];
}
else {
clearInterval(b ackcycler);
This is invalid. You can't specify a function for an interval ID
(hence the new variable I introduced above).

<snip>
Now, I realize the problem is with the "thesubject.onm ouseout =
clearInterval(c ycle); setInterval(bac kcycler,300);" statement, but I can't figure out why it isn't working. I thought you could use event handlers as object properties? Help would be appreciated--thanks.


Hopefully, that will help somewhat.

Mike

--
Michael Winter
M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)
Jul 20 '05 #2

"Michael Winter" <M.Winter@[no-spam]blueyonder.co.u k> wrote in message
news:5Z******** ************@ne ws-text.cableinet. net...
"TheKeith" wrote on 13/11/2003:

<snip>
thesubject.onmo useout = clearInterval(c ycle);

setInterval(bac kcycler,300);

When specifying handlers like this, you must use the function name
only. If you include the parentheses, the function is called
immediately. This means that you can't specify parameters. Also, the
setInterval() call above will always be called: the preceeding
semi-colon marks the end of the assignment. You could put all of your
script on the same line and it wouldn't change how it was executed.
The assignment and setInterval() call are two separate statements. To
fix this, define a new nested function:

function myMouseOut()
{
window.clearInt erval( cycle );
backcycle = setInterval( backcycler, 300 );
// You need the timer ID to cancel the interval later!
}

and add these to your main function:

var backcycle = null; // With the declarations
...
thesubject.onmo useout = myMouseOut;

<snip>
function backcycler() {
if (i > 0) {
i = i - 1;
thesubject.src = theimgs[i];
}
else {
clearInterval(b ackcycler);


This is invalid. You can't specify a function for an interval ID
(hence the new variable I introduced above).

<snip>
Now, I realize the problem is with the "thesubject.onm ouseout =
clearInterval(c ycle); setInterval(bac kcycler,300);" statement, but I

can't
figure out why it isn't working. I thought you could use event

handlers as
object properties? Help would be appreciated--thanks.


Hopefully, that will help somewhat.

Mike

--
Michael Winter
M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)

I'm an idiot. It works great! Thanks a lot, Mike.
Jul 20 '05 #3

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

Similar topics

37
4891
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo
4
4670
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
3877
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
6
8174
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
6
4892
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on a table called COURSES. This table has 2 fields CATEGORY_ID, COURSE_NAME. The CATEGORY_ID is a FK in COURSES and a PK in CATEGORIES. I want to populate the course list box based on any category(s)
4
17872
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
5
5766
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone know a good place to start looking for some theory on the subject of multi user applications? I know only bits and pieces, like about transactions, but a compendium of possible approches to multi user programming would be very appreciated!
5
3283
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify this? Private Sub cmdPreview_Click() On Error GoTo Err_Handler 'Purpose: Open the report filtered to the items selected in the list box. 'Author: Allen J Browne, 2004. http://allenbrowne.com Dim varItem As Variant 'Selected items
0
2327
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08> *********************************************************************** Context
1
9313
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "PAR.PAR_Status" could not be bound. The multi-part identifier "Salary.New_Salary" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part...
0
8944
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...
1
9234
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
9180
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
8186
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...
1
6733
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 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...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4548
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...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3259
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 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.