470,599 Members | 1,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,599 developers. It's quick & easy.

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 1191
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Phil Powell | last post: by
11 posts views Thread by Kelvin Jones | last post: by
5 posts views Thread by pembed2003 | last post: by
35 posts views Thread by michael.casey | last post: by
7 posts views Thread by Csaba Gabor | last post: by
6 posts views Thread by Paul Lautman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.