codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  getting an object`s property which is decided by content of variable.  hermanningjaldsson at 07:49 on Thursday, April 16, 2009
 

In my code i want to access a property of an object.
thing is though that i do now know beforehand which property this is going to be.

Right now it's like this:

the_value = c_object.c_property;


But the thing is that here c_property is a variable,
i want to get the property who's name is the same as the content of c_property.


How do i do that?



  Re: getting an object`s property which is decided by content of variable.  hermanningjaldsson at 08:24 on Thursday, April 16, 2009
 

I got it, the solution is the following:

c_property_value = eval("c_object." + c_property);











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: getting an object`s property which is decided by content of variable.
•  iterate through object properties alphabetically
•  Re: dynamic crystal report generation
•  Re: drop-down menu selected value
•  .net
•  Need help with Network simulator-2 source code
•  code for downloading target file
•  Re: Mouseover Text Change
•  Open a Modal Pop Up From a LinkButton In a GridView


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009