473,769 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LeftHandButtons should turn red(on) but stay blue(off) when mouse on

2 New Member
Hi,

I programmed a web page where two parallel maps can be explored with moving the cursor on the summer and winter buttons. The active button should turn red but now the right hand buttons turn red instead of the left ones. Where's the problem?


[HTML]<HTML>
<META HTTP-EQUIV="Refresh" CONTENT=300>
<HEAD><TITLE>Pa rallel Visual Exploring</TITLE></HEAD>



<SCRIPT LANGUAGE="JavaS cript">

// Animator internal variables

var oldidxLeft = -1;
var oldidxRight = -1;
var isanimLeft = false; // Is animation on
var isanimRight = false;
var timerIDLeft = null;
var timerIDRight = null;


// Data size

var n;


// Preload all images for increased interactive speed

pretimesoffLeft = new Array();
pretimesoffRigh t = new Array ();
pretimesonLeft = new Array();
pretimesonRight = new Array();
preimagesLeft = new Array();
preimagesRight = new Array();
preplayLeft = new Array();
preplayRight = new Array();

function preloadLeft()
{
n = files.length; // Initialize variable here

for(var i=0 ; i<n ; i++)
{
var tmpLeft = timesLeft[i];
pretimesoffLeft[i] = new Image();
pretimesoffLeft[i].src = tbaseLeft+offco lor+tmpLeft+".p ng";
pretimesonLeft[i] = new Image();
pretimesonLeft[i].src = tbaseLeft+oncol or+tmpLeft+".pn g";
preimagesLeft[i] = new Image();
preimagesLeft[i].src = fbase+files[i];
}
preplayLeft[0] = new Image();
preplayLeft[0].src = tbaseLeft+"butt on_play_cyan.pn g";
preplayLeft[1] = new Image();
preplayLeft[1].src = tbaseLeft+"butt on_stop_orange. png";
}

function preloadRight()
{
n = files.length;

for (var i=0 ; i<n ; i++)
{
var tmpRight = timesRight[i];
pretimesoffRigh t[i] = new Image();
pretimesoffRigh t[i].src = tbaseRight+offc olor+tmpRight+" .png";
pretimesonRight[i] = new Image();
pretimesonRight[i].src = tbaseRight+onco lor+tmpRight+". png";
preimagesRight[i] = new Image();
preimagesRight[i].src = fbase+files[i];
}
preplayRight[0] = new Image();
preplayRight[0].src = tbaseRight+"but ton_play_cyan.p ng";
preplayRight[1] = new Image();
preplayRight[1].src = tbaseRight+"but ton_stop_oranss i.png";
}

// Function to change to a new time and picture on left

function showpngLeft(idx Left,overLeft) {

if(idxLeft==old idxLeft) return;

if(idxLeft == n)
{
if(!isanimLeft)
{
isanimLeft = true;
timerIDLeft = setTimeout("doa nimLeft()",dela y);
}
document.images["img"+n].src = preplayLeft[1].src;
}
else
{
if(overLeft)
{
document.images["img"+n].src = preplayLeft[0].src;
if(timerIDLeft) clearTimeout(ti merIDLeft);
isanimLeft = false;
}
if(oldidxLeft >= 0)
document.images["img"+oldidxLef t].src = pretimesoffLeft[oldidxLeft].src;

document.images["img"+idxLe ft].src = pretimesonLeft[idxLeft].src;
document.images["predictionLeft "].src = preimagesLeft[idxLeft].src;
oldidxLeft = idxLeft;
}
}

// Function to change to a new time and picture on right

function showpngRight(id xRight,overRigh t) {

if(idxRight==ol didxRight) return;

if(idxRight == n)

{
if(!isanimRight )
{
isanimRight = true;
timerIDRight = setTimeout("doa nimRight()",del ay);
}
document.images["img"+nRigh t].src = preplayRight[1].src;
}
else
{
if(overRight)
{
document.images["img"+n].src = preplayRight[0].src;
if(timerIDRight ) clearTimeout(ti merIDRight);
isanimRight= false;
}
if(oldidxRight >= 0)
document.images["img"+oldidxRig ht].src = pretimesoffRigh t[oldidxRight].src;

document.images["img"+idxRi ght].src = pretimesonRight[idxRight].src;
document.images["predictionRigh t"].src = preimagesRight[idxRight].src;
oldidxRight = idxRight;
}
}

function doAnimLeft() {
if(!isanimLeft) return;
showpngLeft( (oldidxLeft+1) % n , 0 );

if(oldidxLeft+1 ==n)
timerIDLeft = setTimeout("doa nimLeft()",wrap delay);
else
timerIDLeft = setTimeout("doa nimLeft()",dela y);
}

function doAnimRight() {

if (!isanimRight) return;
showpngRight( (oldidxRight+1) % n, 0);

if(oldidxRight+ 1==n)
timerIDRight = setTimeout("doa nimRight()",wra pdelay);
else
timerIDRight = setTimeout("doa nimRight()",del ay);
}

// Function called to setup the animation

function restart() {
if(timerIDLeft) clearTimeout(ti merIDLeft);
isanimLeft = false;
showpngLeft(0,1 );
// showgif(n-1,1); // last gif
// showgif(n,1); // nth = PLAY

if(timerIDRight ) clearTimeout(ti merIDRight);
isanimRight = false;
showpngRight(0, 1);

}

// Function to produce standard HTML body

function makeAnimBodyLef t()
{
document.writel n('<TABLE BORDER=0 ALIGN=LEFT>');
document.writel n('<TR><TD>');

document.writel n('<TABLE BORDER=0 ALIGN=LEFT CELLPADDING=0 CELLSPACING=0>' );
for(i=0 ; i<n ; i++) {
var tmpLeft = timesLeft[i];
document.writel n('<TR><TD><A HREF="javascrip t:void(0)" onMouseOver="sh owpngLeft('+i+' ,1)">');
document.writel n('<IMG ALIGN=MIDDLE HSPACE=0 VSPACE=0 NAME="img'+i+'" SRC="'+pretimes offLeft[i].src+'"></A>');
document.writel n('</TD></TR>');
}
document.writel n('<TR><TD><A HREF="javascrip t:void(0)" onMouseOver="ja vascript:showpn gLeft('+n+',1)" >');
document.writel n('<IMG ALIGN=MIDDLE HSPACE=0 VSPACE=0 NAME="img'+n+'" SRC="'+preplayL eft[0].src+'"></A></TD></TR>');
document.writel n('</TABLE>');

document.writel n('</TD><TD>');

document.writel n('<TABLE BORDER=0 ALIGN=CENTER>') ;
document.writel n('<TR ALIGN=LEFT>');
document.writel n('<TD><IMG BORDER=1 NAME="predictio nLeft" SRC="'+preimage sLeft[0].src+'"></TD>');
document.writel n('</TR>');
document.writel n('<TR ALIGN=CENTER><T D></TD>');
document.writel n('</TR>');
document.writel n('</TABLE>');

document.writel n('</TD><TD>');
document.writel n('</TD></TR>');
document.writel n('</TABLE>');
}

function makeAnimBodyRig ht()
{
// For the map on the right hand site.
document.writel n('<TABLE BORDER=0 ALIGN=LEFT>');
document.writel n('<TR><TD>');

document.writel n('<TABLE BORDER=0 ALIGN=LEFT CELLPADDING=0 CELLSPACING=0>' );
for(i=0 ; i<n ; i++) {
var tmpRight = timesRight[i];
document.writel n('<TR><TD><A HREF="javascrip t:void(0)" onMouseOver="sh owpngRight('+i+ ',1)">');
document.writel n('<IMG ALIGN=MIDDLE HSPACE=0 VSPACE=0 NAME="img'+i+'" SRC="'+pretimes offRight[i].src+'"></A>');
document.writel n('</TD></TR>');
}
document.writel n('<TR><TD><A HREF="javascrip t:void(0)" onMouseOver="ja vascript:showpn gRight('+n+',1) ">');
document.writel n('<IMG ALIGN=MIDDLE HSPACE=0 VSPACE=0 NAME="img'+n+'" SRC="'+preplayR ight[0].src+'"></A></TD></TR>');
document.writel n('</TABLE>');

document.writel n('</TD><TD>');

document.writel n('<TABLE BORDER=0 ALIGN=CENTER>') ;
document.writel n('<TR ALIGN=LEFT>');
document.writel n('<TD><IMG BORDER=1 NAME="predictio nRight" SRC="'+preimage sRight[0].src+'"></TD>');
document.writel n('</TR>');
document.writel n('<TR ALIGN=CENTER><T D></TD>');
document.writel n('</TR>');
document.writel n('</TABLE>');

document.writel n('</TD><TD>');


// map legend
document.writel n('<TABLE BORDER=0 ALIGN=CENTER>') ;
document.writel n('<TR ALIGN=LEFT>');
document.writel n('<TD><IMG BORDER=0 SRC="Legend.png " width="349" height="420"></TD>');
document.writel n('</TR>');
document.writel n('<TR ALIGN=CENTER><T D></TD>');
document.writel n('</TR>');
document.writel n('</TABLE>');

document.writel n('</TD></TR>');
document.writel n('</TABLE>');
}

// Animation settings

var delay = 2000; //Animation speed
var wrapdelay = 4000;// Wrap-around delay

var tbaseLeft = "./Nappulat/"; // Base name for time steps
var tbaseRight = "./Namiskat/"; // Base name for time steps
var fbase = "./"; // Base name for map files
var oncolor = "red";
var offcolor = "blue";


var files = new Array(
"aniframe_0015_ 1.jpg", "aniframe_0014_ 2.jpg",
"aniframe_0013_ 3.jpg", "aniframe_0012_ 4.jpg",
"aniframe_0011_ 5.jpg", "aniframe_0010_ 6.jpg",
"aniframe_0009_ 7.jpg", "aniframe_0008_ 8.jpg",
"aniframe_0007_ 9.jpg", "aniframe_0006_ 10.jpg",
"aniframe_0005_ 11.jpg", "aniframe_0004_ 12.jpg",
"aniframe_0003_ 13.jpg", "aniframe_0002_ 14.jpg",
"aniframe_0001_ 15.jpg", "aniframe_0000_ 16.jpg");

var timesLeft = new Array("+1stSumm er","+1stSummer ","+Winter","+2 ndSummer","+Win ter", "+3rdSummer","+ Winter","+4thSu mmer","+Winter" ,"+5thSummer ",
"+Winter","+6th Summer","+Winte r","+7thSummer" ,"+Winter","+8t hSummer");

var timesRight = new Array("+1stSumm er","+1stSummer ","+Winter","+2 ndSummer","+Win ter", "+3rdSummer","+ Winter","+4thSu mmer","+Winter" ,"+5thSummer ",
"+Winter","+6th Summer","+Winte r","+7thSummer" ,"+Winter","+8t hSummer");

preloadLeft(); // Must be after the SSI
preloadRight();

</SCRIPT>

</HEAD>

<BODY BGCOLOR=white onLoad="restart ()">
<CENTER>
<H2><FONT COLOR=black>Com pare Occurrence Probabilities of Colorado Beetle</FONT></H2>


<!-- A HREF="_EuropeCD .html"><FONT COLOR="blue">Tu lostussivu Z EuropeCD</FONT></A -->
</CENTER>
<BODY LINK=white VLINK=white ALINK=white>

<SCRIPT LANGUAGE="JavaS cript"><!--
makeAnimBodyLef t();
makeAnimBodyRig ht();
// -->
</SCRIPT>



<NOSCRIPT>
Sivu vaatii v&auml;hint&aum l;&auml;n Netscape 4.0 tai Internet Explorer 4.0
selaimen, ja ett&auml; JavaScript on p&auml;&auml;ll &auml;.
</NOSCRIPT>

</BODY>

</HTML>[/HTML]
Feb 4 '08 #1
2 1270
epots9
1,351 Recognized Expert Top Contributor
Moved to the Javascript Forums where the resident experts can better assist you. Also please remember to use code tags.

**Moved from Programming Challenges.
Feb 4 '08 #2
gits
5,390 Recognized Expert Moderator Expert
... merged threads ...

kind regards
MODERATOR
Feb 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2305
by: Don | last post by:
Setting: chruch multimedia computer and projection system, with 2 display monitors. The projector is connected to monitor #2. Is there some way using JavaScript I can display a ".jpg" picture on display #2? I know how to send the <form> tag to turn on/off the projector, but don't know how to put up a picture. I don't want any browser artifacts to show. Just the picture. Thanks, Don
2
2970
by: AK | last post by:
My understanding is that unlike CHAEK and FOREIGN KEY constraints, we cannot have UNIQUE ones NOT ENFORCED, and the reason is very simple: UNIQUE constraints are implemented as UNIQUE indexes. One cannot turn off uniquenedss of an index easily Am I correct?
2
6830
by: deko | last post by:
I want to turn error handling off, then back on in a sub routine that backs up a select set of documents. For some reason, I can't seem to get this to work - Private Sub BackupDocs() On Error GoTo HandleErr strBackupDir = "C:\BackupDir" On Error GoTo 0 ' isn't this supposed to turn off error trapping?
2
2968
by: Steve Franks | last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting a value in the config.web file. However, what if I wanted to determine at run time whether or not I wanted to use cookieless sessions for a particular user, and if so, I'd instruct ASP.NET to turn on cookieless sessions for a particular user session. Is this possible? For example I want to use cookie based sessions by default for all users. But if a user has...
10
23604
by: Zabby | last post by:
hi, i want to turn on/turn off a usb lamp via a vb.net button... i think i would have to turn on/turn off the power for this usb port.... how could i do this? kind regards
4
22005
by: Gidi | last post by:
Hi, Is it possible to turn on\off the CAPS LOCK button using C# program? and if so, how can i do that? Thanks, Gidi
1
1925
by: shror | last post by:
Hi every body, i want to know how i can use two radio buttons to turn on/off a midi file on my webpage, so that if the midi is running and i choose the off radio button then the midi is switched off instantly without any loading. is that possible or not, and if possible please tell me how to do it. Thanks shror www.s7els7.com
4
10349
by: BLUE | last post by:
Psion WorkAbout Pro with Windows CE .NET 4.2 Dealer gave me PowerAPIOn.exe and PowerAPIOff.exe to turn on/off tag reader, but I want to do it programmatically and do the same with WiFi and Bluetooth as I can do from Control Panel ("Network and dialup connections" and "Power"). Googling I've found that I should:
0
4150
by: BLUE | last post by:
I'll let you know what the dealer and the manufacturer will answer me as soon as possible. As far as now I've been capable or turning ON/OFF: - the RFID reader using dealer supplied executables (PowerAPIon/off.exe) - CF WiFi and any other expansion card using "Psion Mobile Devices SDK"
0
1981
by: Emilio | last post by:
Good morning, I'm developing in C# with Visual Studio 2008 .NET and .NET Compact framework 2.0 on Windows CE 5.0 . Which are the libraries that by means I can control display backlight and, generally, display turn on/off ? Thank you for your help. Emilio.
0
9579
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
9416
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
10199
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...
0
10032
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 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...
1
9979
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
9849
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
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
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
3
2810
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.