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

Arrays Quirk

Hi,

I have a script where b) works perfectly but a) carries out only
select_onchange[0]. Any ideas on why? (everything else is the same,
problem in FF and IE). No errors / warnings.

John

a)

for(i=0; i<3; i++) {
select_onchange(tempArray[i]);
}

b)

select_onchange(tempArray[0]);
select_onchange(tempArray[1]);
select_onchange(tempArray[2]);
Jul 23 '05 #1
2 1037
John wrote:
I have a script where b) works perfectly but a) carries out only
select_onchange[0]. Any ideas on why? (everything else is the same,
problem in FF and IE). No errors / warnings.

a)

for(i=0; i<3; i++) {
select_onchange(tempArray[i]);
}

b)

select_onchange(tempArray[0]);
select_onchange(tempArray[1]);
select_onchange(tempArray[2]);


'i' is a global variable, so perhaps something in your select_onchange
function is also using the same global variable 'i' which could cause the
loop to terminate prematurely?

I suggest you make sure that your for loop is inside a function and declare
'i' as a local variable.
Jul 23 '05 #2
Duncan Booth wrote:
John wrote:

I have a script where b) works perfectly but a) carries out only
select_onchange[0]. Any ideas on why? (everything else is the same,
problem in FF and IE). No errors / warnings.

a)

for(i=0; i<3; i++) {
select_onchange(tempArray[i]);
}

b)

select_onchange(tempArray[0]);
select_onchange(tempArray[1]);
select_onchange(tempArray[2]);

'i' is a global variable, so perhaps something in your select_onchange
function is also using the same global variable 'i' which could cause the
loop to terminate prematurely?

I suggest you make sure that your for loop is inside a function and declare
'i' as a local variable.


Fixed. Thank you very much. I naively assumed that it would work like
java. I was nowhere near fixing it until you told me that.

John
Jul 23 '05 #3

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

Similar topics

19
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
2
by: shaun roe | last post by:
As a follow up to my question about STL and bitset<64> I'd like to share a quirk (bug?) about unsigned long long support and the bitset. I'm using gcc 3.2 on linux or gcc 3.3 on mac, the answer is...
1
by: Peter Billam | last post by:
Greetings. This problem arises in the context of the CPAN module Crypt::Tea ... It works with IE, Mozilla, Netscape, Firefox, IE and Opera, but if you check out...
5
by: Roland Bengtsson | last post by:
Is it possible to determine if the www-reader is in quirk mode and then do a printout on the status line at the bottom?
23
by: Mark Dickinson | last post by:
I have a simple 192-line Python script that begins with the line: dummy0 = 47 The script runs in less than 2.5 seconds. The variable dummy0 is never referenced again, directly or indirectly,...
4
by: mux | last post by:
Hi I found out that the following piece of code throws an error. 1 #include "stdio.h" 2 3 int main() 4 { 5 int a,b; 6 a= 10;
15
by: Paul Morrison | last post by:
Hi all, I need to come up with some differences between arrays in Java and C, I have searched Google and so far all I have found is the following: Arrays in Java are reference types with...
5
by: JezB | last post by:
What's the easiest way to concatenate arrays ? For example, I want a list of files that match one of 3 search patterns, so I need something like DirectoryInfo ld = new DirectoryInfo(searchDir);...
1
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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...
0
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...
0
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...
0
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,...
0
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...

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.