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

function fails on second use?

I have this called by the onclick handler on a radio button group:

function loadContacts(myForm){
myForm.Contact.options.length= 0;
var gpList = getSelectedRadioValue(myForm.Group_Name);
var useList = new Array();
useList = makeArray(gpList);
//alert(useList[0][0]);
if (useList !== '') {
var x = useList.length;
for (x = 0; useList[x]; x++) {
myForm.Contact.options[x] = new Option(useList[x][0],
useList[x][1],false,false);
}
}
}

I runs fine on first use and a drop-down is list is filled with names
and their email address as a value. When I click a second radio button
(even the currently selected one) , the script fails at this line:
useList = makeArray(gpList); - saying 'function expected'. Why it worked
first time round. FWIW, there are no global vars in play.

I've tried setting useList = null at before quitting the function but it
should be destroyed as it goes out of scope when the function finishes.

Any ideas?

Regards

Mark
Jul 23 '05 #1
2 1243
Lee
Mark Anderson said:

I have this called by the onclick handler on a radio button group:

function loadContacts(myForm){
myForm.Contact.options.length= 0;
var gpList = getSelectedRadioValue(myForm.Group_Name);
var useList = new Array();
useList = makeArray(gpList);
//alert(useList[0][0]);
if (useList !== '') {
var x = useList.length;
for (x = 0; useList[x]; x++) {
myForm.Contact.options[x] = new Option(useList[x][0],
useList[x][1],false,false);
}
}
}

I runs fine on first use and a drop-down is list is filled with names
and their email address as a value. When I click a second radio button
(even the currently selected one) , the script fails at this line:
useList = makeArray(gpList); - saying 'function expected'. Why it worked
first time round. FWIW, there are no global vars in play.

It sounds as if you're assigning some value to a variable
named "makeArray" that's clobbering the use of that name
as a function. My first guess would be that you're doing
that within the makeArray function, itself.

Also note that it's redundant to assign a new Array to
useList and then immediately replace that new Array with
a different one. Use:

var useList = makeArray(gpList);

Jul 23 '05 #2
>>>My first guess would be that you're doing
that within the makeArray function, itself.<<<

bingo!

Thanks.

Mark

Jul 23 '05 #3

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

Similar topics

0
by: Phil Powell | last post by:
<?php class Grad { var $dbFormExemptionArray = array(); function Grad ($id = '') { ...
11
by: Kelvin Jones | last post by:
Hey, I am trying to write a custom assert function that would be used to forward a user to an error page if the assertion fails. Here is the definition of this function and an example of its...
2
by: info | last post by:
I am pasting in a recordset from access to an excel sheet via VBA successfully. Then my routine copies a range of cells and pastes them into another range, this works fine every other time it...
5
by: pembed2003 | last post by:
Hi all, I need to write a function to search and replace part of a char* passed in to the function. I came up with the following: char* search_and_replace(char* source,char search,char*...
35
by: michael.casey | last post by:
The purpose of this post is to obtain the communities opinion of the usefulness, efficiency, and most importantly the correctness of this small piece of code. I thank everyone in advance for your...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
7
by: Csaba Gabor | last post by:
I feel like it's the twilight zone here as several seemingly trivial questions are bugging me. The first of the following three lines is a syntax error, while the last one is the only one that...
6
by: Paul Lautman | last post by:
Here's something that I can't manage to find explicitly documented. In the following snippet: function outer() { global $a; function inner() { global $a; echo $a.'1<br>'; } $a = 's';
1
by: comp.lang.php | last post by:
I thought my function would have accomplished just that: if (!function_exists('resetCSV')) { function &resetCSV($fullFileName, $path, $willClearFile = false) { ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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
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...

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.