Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to pass array element name?
Message
 
 
To
30/11/2015 11:08:27
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01628031
Message ID:
01628081
Views:
32
>>>comments can be misleading: untested
>>>
>>>function MyTest( cCol1Name ) {
>>>var MyObject = .... object is created
>>>var Row = MyObject[0].cCol1Name;
>>>var Col1Val = Row[cCol1Name]
>>>// var Col1Val = eval( "Row." + cCol1Name)
>>>}
>>>>>>
>>
>>Thank you.
>
>The commented eval() should work as well, but is considered by some to be an anti-pattern. Was a bit short in my explanation ;-)

I am very much a newbie to javascript. So I will look up this function; use, upside and downside. One thing I found so far is that javascript is very unforgiving. If I have ANYTHING wrong in my javacript (like, e.g., missing the ending ";") nothing works in the code. And no error appears when I am running it in ASP.NET. I have to be extra careful.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform