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 3612720
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:02:09+00:00 2026-05-18T22:02:09+00:00

I have below probably a bunch of problems but let’s simplify them with easier

  • 0

I have below probably a bunch of problems but let’s simplify them with easier examples.

Let assume two vars, a=cat and b=a, and you want to reference by bs value a to that var ie a. So by which command I can do it? Variable SomeCommand(b) and variable a should point to the same memory space becaues b gets evaluated to a. The same question arises from the below code where we have the part document.getElementById(vals[0].split('|')[0]).style.display= 'block'; that should be evaluated to document.getElementById(picture).style.display= 'block'; ie to show picture but the above example is much cleaner to explain so refer to it, please. How to do the reference? Are the two ways above equivalent? I am watchful here because having encountered similar problems in other languages but then they were about inodes, symbolic/hard links and such things but no idea how this works in JS. Shortly, how do they get evaluated?


function change_visibility(binX)

{
     // binX is a thing that matches `/^[10Xx]+$/`
     // 1 = show the thing
     // 0 = do not show the thing
     // x/X = do not do anything
     //
     // for example, 00011x would turn OFF picture-quote-question_mark 
     // while turning ON search and help but not doing anything to 
     // typing pad's current state


        var vals = ['picture|binX.charAt(0)',
                        'quote|binX.charAt(1)',
                        'question_mark|binX.charAt(2)',
                        'search|binX.charAt(3)',
                        'help|binX.charAt(4)',
                        'typingPad|binX.charAt(5)'
                        ];

        for (var i=0; i<vals.length; i++)
        {
                if(vals[i].split('|')[1]==1)
                {
                        //TODO: check whether you can do it like this, 
                        // assumed for example that vals[0].split('|')[0] =picture
                        // but it is not, the "inode" or let call it arrow is diffent!
                        // ERROR HERE ?!?
                        document.getElementById(vals[i].split('|')[0]).style.display= 'block';
                }
                else if(vals[i].split('|')[1]==0)
                {
                        document.getElementById(vals[i].split('|')[0]).style.display= 'none';
                }
        }

}

Please, fix the labels if you know more descriptive alternatives.

  • 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-18T22:02:10+00:00Added an answer on May 18, 2026 at 10:02 pm

    You might want to revise your question. I’m not entirely sure what you’re asking. Is there a problem with this code you can’t figure out? What is it suppose to do? The whole a, b reference portion of the conversation has nothing to do with the code you submitted. The variable you’re passing isn’t used in your code. Also your if statement compares the split to == 1. But, it will never be equal to 1 or 0. It will only be one of those phrases to the right of ‘|’. Anyway maybe you can revise your question and it will make more sense.

    Let me rewrite your code a little so you don’t have that binX junk in the array.

    function change_visibility(binX) {
    
    var vals = ['picture',
                    'quote',
                    'question_mark',
                    'search',
                    'help',
                    'typingPad'
                    ];
    
    for (var i=0; i<vals.length; i++) {
            var val = binX.charAt(i);
    
            if(val=='1') {
               document.getElementById(vals[i]).style.display= 'block';
            } else if(val=='0') {
               document.getElementById(vals[i]).style.display= 'none';
            }
    }
    }
    

    That might have been what you were after. So if binX is ‘10000’ then ‘picture’ would be shown, and the rest would be hidden. Maybe that’s what you were after. This solution is better because you aren’t using eval() which you should avoid if you don’t have to, and this code you don’t have to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.