pass a pointer to an array in a JS function
Posted: Mon Apr 17, 2006 12:03 pm
I am creating a function in JS that will loop over checkboxes and check them if necessary.
I have created a few arrays for the different sets of checkboxes above my function and I need to point to those arrays in one of my function arguments.
I know I"ve done this before but I can't remember where or how...here's an ex:
unforutnately I can't pass the array variable itself in my function call because it's not defined at that point. I'm passing it as a string (the name of the array) and it's not flying.
I've also tried creating an associative multidimensional array and passing the name of the array I need to loop as the key of my array...still no go.
any ideas?
thx,
Burr
I have created a few arrays for the different sets of checkboxes above my function and I need to point to those arrays in one of my function arguments.
I know I"ve done this before but I can't remember where or how...here's an ex:
Code: Select all
var someArr = Array('one','two','three');
var someOtherArr = Array('four','five','six');
function checkAll(obj,whichArr)
{
if(obj.checked)
{
for(i=0;i<whichArr.length;i++)
//etc...
}
}I've also tried creating an associative multidimensional array and passing the name of the array I need to loop as the key of my array...still no go.
any ideas?
thx,
Burr