Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7508285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:39:13+00:00 2026-05-29T22:39:13+00:00

I’m only working on my 3rd Javascript project, so this is probably easy to

  • 0

I’m only working on my 3rd Javascript project, so this is probably easy to answer (at least I hope so).

I have learned to use JS object in place of arrays. In this project I have named multiple object with a nested system of IDs as follows:

animalia = new Object();
animalia.chordata = new Object();
animalia.chordata.actinopterygii = new Object();
animalia.chordata.actinopterygii.acipenseriformes = new Object();
etc.......

I’m having problems calling on objects named this way though. Here is my code:

function expand(event){
    var target = event.target;
    console.log(target);
    var parent = target.parentNode;
    console.log(parent);
    var parentclass = parent.getAttribute("class");
    console.log(parentclass);
    if (parentclass == "kingdom"){
        var newdiv = document.createElement("div");
        var newexpctrl = document.createElement("div");
        var parentid = parent.getAttribute("id");
        console.log(parentid);  
  ----> var parentobj = window[parentid];
        console.log(parentobj);}
    else{
        var upperclass = searchArray(parentclass);
        console.log(upperclass);
        var newdiv = document.createElement("div");
        var newexpctrl = document.createElement("div");
        var parentId = parent.getAttribute("id");
        console.log(parentId);
        var parentnode_ = document.getElementById(parentId);
        console.log(parentnode_);
        var gparentId = parentnode_.parentNode.id;
        console.log(gparentId);
  ----> var parentobj = window[gparentId.parentId];
        console.log(parentobj);
    }
    var childnumb = parentobj.children;
}

I am having my problem with the two statements indicated by “—->”. In the first case, using a single variable works for pulling up the proper object. However, in the second case, using two variables, I fail to be able to access the proper object. What is the proper syntax for doing this? I have tried a plethora of different syntax combinations, but nothing seems to work correctly. Or should is there a better method for calling on JS objects other than using “window[variable]”?

P.S.- If you haven’t figured it out by now, I am working on educational tools for use in learning biology. Thanks once again stackoverflow, you guys rule.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:39:14+00:00Added an answer on May 29, 2026 at 10:39 pm

    Assuming that the window object has something w/ the property matching a string that’s the value of gparentId, you should be able to do:

    var parentobj = window[gparentId][parentId];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.