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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:53:31+00:00 2026-05-15T15:53:31+00:00

I am stumped by a problem which i’d assume is a common Jquery occurence,

  • 0

I am stumped by a problem which i’d assume is a common Jquery occurence, but i’ve no idea how to fix!

I have 5 variables –

 var pubtimed 
 var toolstimed 
 var newstimed 
 var mylinkstimed 
 var partnerstimed 

Which are used to store on and off states.
I then have a script that checks cookies for recent states and updates the variables accordingly, then forwards the details onto a render function –

var map = {
    'pub': $.cookie('nwphportal_tabExpPub'),
    'tools': $.cookie('nwphportal_tabExpTools'),
    'news': $.cookie('nwphportal_tabExpNews'),
    'mylinks': $.cookie('nwphportal_tabExpLinks'),
    'partners': $.cookie('nwphportal_tabExpPartners')
}

$.each(map, function (key, value) {
    if (value != null) {
        var varname = key + 'timed';
        varname = value;
        renderScrn(varname)
    } else {
        var varname = key + 'timed';
        varname = "1"
        renderScrn(varname)
    }
});

The problem I have is that I want the variable varname to be treated as each of the 5 variables above (e.g. key plus timed = pubtimed). But this doesnt happen and I just get an error. I could just place a list of if statements to fix this, but wondered if there were a better solution?

Please help if you can!

Cheers for your time.
Paul

  • 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-15T15:53:32+00:00Added an answer on May 15, 2026 at 3:53 pm

    If they’re global variables, you can do this:

    window[key + 'timed'] = value;
    

    If they’re not global (though they look so from what you posted), then you’ll have to keep them in a container object, kind-of like your “map”:

    var container = {
      pubtimed: null,
      // ...
    };
    
    // ...
    
        container[key + 'timed'] = value;
    

    edit — as @galambalazs wrote in his answer, it’d be better to avoid doing this. If you set up a container, just use the keys directly.

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

Sidebar

Related Questions

Ok, I'm stumped by this one I have no idea what's causing this problem.
I am new to rails development. I have a simple problem but Im stumped
The following problem has me stumped: I have a WinForms application which used to
I have been stumped all day on this problem. Basically I want to check
I have been stumped for 3 hours now on this problem, I need to
I'm stumped. There are several threads out there that reference a similar problem, but
I have a problem which is either something I have completely failed to understand,
Greetings, I have a problem which would seem to involve some kind of z-index
I have encountered a problem in my program that has me somewhat stumped. I
I'm really stumped on this issue. I have a problem where Java can't find

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.