Jump to content

How to save value of object instead of string


Mishmashek

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";
      debugger;
      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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...