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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:09:55+00:00 2026-06-18T04:09:55+00:00

I added a var in the parameter in the function: // msg = test

  • 0

I added a var in the parameter in the function:

//
msg = "test message";
date = "02-28-2013";
cal.setData({ date : msg});
//
//this can't work

However, the following one works well

//
msg = "test message";
cal.setData({ "02-28-2013" : msg});
//

but I need to use the one containing var.
How can I make it work?

thanks

  • 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-06-18T04:09:56+00:00Added an answer on June 18, 2026 at 4:09 am

    Try this:

    var param = {}
    param[ date ] = msg;
    cal.setData( param );
    

    In order to set a variable as the property name for an object, you have to use the bracket notation. To do so, first create an empty object, then add the dynamic property like seen above.

    In your first example, the object, that is passed to the function, contains a property named date and not a property with the name of the value of the variable date.

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

Sidebar

Related Questions

In some projects that I work, was added some blocks with this syntax: var
//This is the function that will run every time a new item is added
I have added a function to check for language parameter to my AppController function
I added this part of the code in my onCreate() method and it crashes
UPDATE: Added doGet function. I have a web app that is used for a
I realized how bad I am with javascript :( I have this: function getUrlVars()
I have been trying this for a while now and can't get it to
I have a JavaScript function to which I pass a parameter. The parameter represents
function parseAttach(b) { var h=; for(i=0;i<b.length;i++) { var a=b[i]; switch(a['type']) { case image: h+='<li
I have the following code: var formSubmitHandler = function (link, form) { //e.preventDefault(); var

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.