Passing JSON object name into function with Javascript -


I am returning a string to the function and returning that string's Jason object.

Objname is a string, such as "ky1"

  function myFunction (objname) {return myjsonobj.objname; }   

How can I get the above to parse correctly? This is a simple example, but it shows what I am trying to achieve.

I am not using jQuery, this is not an option for me in this work.

Thanks

  Try with return   

< P> myjsonobj [objname];

If you type that with dot notation you are looking for the key to the name " objname ", but in your example this is only a variable.

Comments