Jump to content

How to save value of object instead of string

Recommended Posts

function loadDoc(n_file) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      var myObj = JSON.parse(this.responseText);
      var parametr = "september"
      var neco = myObj.september.17[0].dayname;
      var neco2 = "myObj." + parametr + ".17[0].dayname";
      x = zacinajiciDen(neco);
than i have this in my variables:

neco1: "pa"
neco2: "myObj.september17[0].dayname"

i would like to have value "pa" inside like in neco1 but i would like to be able to change name of month. Is it possible 


Hi all,


I have a simple problem.  I would like to have a value of Object  "myObj.september17[0].dayname" in my variable neco2. but there is of course more month which i need access and i need to changing this variable but when i use "myObj." + parametr + "17[0].dayname"; it is saved a string to variable instead of value.




I am very new in JS, learning two days now so please be patient with me.



Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...