array values are being passed as variable names?
I'm trying to add a function call to an array to be used later. It works when passing numbers/strings as parameters [e.g. "myfunction(1, 'x')" is added and called successfully later]. However, I need to store an array of values as a parameter in the function for use later [e.g. myArray=[string0,string1,string2]; myfunction(1, 'x', myArray)]. But it looks for an object string0 when called as opposed to just passing the string as a string.
Here's a simplified version of what i'm trying to do in code:
If f1 is called...
var holdFunction = new Array();
var myArray=[myObj.innerHTML, var1, var2];
The alert box (if uncommented) shows:
And the line to run the script prompts the error:
But I need the array to stay an array with static text/number values to manipulate as an array in f2. I feel there's a simple solution I'm overlooking. Any ideas would be appreciated.
Error: 'test' is undefined
Last edited by speghettiCode; 05-19-2009 at 06:26 AM.
The simplest way would be:
Which will insert quotes into the strings to be parsed as string enclosing quotes later.
var myArray=['"' + myObj.innerHTML + '"', var1, '"' + var2 + '"'];
[RESOLVED]array values are being passed as variable names?
That's what I needed. I'm a bit embarassed by the simplicity of the solution i had overlooked; but I'm glad it's working. Thanks!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)