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"
},
...
Bracket notation is the right answer, but as you seem to be asking how to pass it, too, construct like this