Click to See Complete Forum and Search --> : Get a variable name into a string
bokeh
02-03-2006, 04:15 AM
Get the name of a variable into a string
myVar = '12345';
myVarName = ?***?;
/*
myVarName now contains the string "myVar"
*/
Simplest possible way please
Charles
02-03-2006, 04:26 AM
myVarName = 'myVar'Perhaps I'm missing something here. What exactly are you up to?
bokeh
02-03-2006, 04:52 AM
function array_to_get(sendTo,theArray)
{
output = '';
for(i=0;i<theArray.length;i++){
glue = (i)?'&':'?';
output += glue+'myArray['+i+']='+theArray[i];
}
window.location = sendTo + output;
}I wanted the words myArray to reflect the real name of the array as passed to it by the event handler. (i.e. dynamic)
Charles
02-03-2006, 05:40 AM
You can't get that. You need to send the name along as well inthe function call. But this looks like a good place for objects. Send some objects instead. Or better yet, define a class and let each member inherit a method.
bokeh
02-03-2006, 05:59 AM
OK, maybe I am trying to over simplify things. Anyway it's not important. I just wanted to make it dynamic. I could always add a third argument I guess; This would probably be better so I could name them independantly.
Charles
02-03-2006, 06:13 AM
I'd use a class of objects. It's very trendy.
bokeh
02-03-2006, 06:17 AM
I'd use a class of objects. It's very trendy.I suck at OO but I'm trying to learn.