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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:45:15+00:00 2026-06-11T12:45:15+00:00

Basic Javascript/jQuery question: How can I use a nonliteral for the key in a

  • 0

Basic Javascript/jQuery question: How can I use a nonliteral for the key in a key/value pair? I thought the following syntax (below) would parse, but it does not. I am trying to make a dialog that is dynamic. I want the button text to be variable. How can I do this with Javascript/jQuery? Or do I have to invoke PHP on my .js file? (So don’t want to do this…)

function see_menu_custom(t1, m1, t2, m2, t3, m3, t4, m4, t5, m5)
{   
    $(document).simpledialog2(
    { 
        mode: 'button',
        headerText: 'Send Message',
        headerClose: true,
        showModal: true,
        animate: false,
        buttons :
        {
            t1: /******** How can I make this a nonliteral? *********/
            {
                click: function () { 
                    sendMessage(username, token, t1, m1);
                },
                iconpos : "right",
                icon : "arrow-r",
                theme : "e"
            },
...
  • 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-11T12:45:16+00:00Added an answer on June 11, 2026 at 12:45 pm

    Bracket notation is the right answer, but as you seem to be asking how to pass it, too, construct like this

    function see_menu_custom(t1, m1, t2, m2, t3, m3, t4, m4, t5, m5)
    {   
        var myButtons = {};
        myButtons[t1] = {
            click: function () { 
                sendMessage(username, token, t1, m1);
            },
            iconpos : "right",
            icon : "arrow-r",
            theme : "e"
        };
        // rest of buttons
        ...
        // then pass into next step
        $(document).simpledialog2(
        { 
            mode: 'button',
            headerText: 'Send Message',
            headerClose: true,
            showModal: true,
            animate: false,
            buttons : myButtons, // here
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just refreshing my JavaScript/Jquery skills and I thought of making a basic
I've just started learning jQuery/javascript, so this might seem like a really basic question,
I need to use basic javascript here and I'm not well versed with it.
This could be a very basic Javascript I know but I just can't get
This may seem like a basic/stupid/obviously-answered question, but I wanted to check: why use
I am studying html, css, javascript and jquery in a very basic level yet,
This is probably a fairly easy question, but I'm new to JavaScript and jquery....
Gentlepeeps, I'm new with Jquery. Apologies in advance for the basic question. I'm trying
I have a question with jQuery. Can one not pass the id's to a
I'm trying to learn jquery, I've some basics of javascript. I've written this piece

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.