Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript: dynamic query/condition build help

 
Sridhar Ranganthan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

iam creating dynamic button using javascript via kony.

function dynaButton()
{

var layoutprop={ widgetdatamap {"btn1" : "btn1", "btn2" : "btn2"}};


}
i would like to create n no of buttons,so in that case "btn1" : "btn1", "btn2" : "btn2","btn3" : "btn3", "btn4" : "btn4"..."btnn" : "btnn"


i have tried in this approach

var myId;
function getId()
{

for(var i=1;i<n;i++)
{
myId=myId+"btn"+i+":btn"+i;
if(i<n)
{
myId=myId+",";
}
return myId;
}

and then i have placed like this

var getBtnId=getId();

var layoutprop={ widgetdatamap {getBtnId}};

but it return error, i guess ,it cause of : operator .

can you please how to sort out this problem.

i want to place "btn1" : "btn1" , "btn2" : "btn2" in { widgetdatamap { } }


Thanks,
Sridhar.R
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use an object! Do not build an object from a string.



Eric
 
Sridhar Ranganthan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

Thank you for your reply,

can you explain more that will helpful for me.

Thanks,
Sri.R
 
Sridhar Ranganthan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Iam going to create dynamic button,so inside "widgetDataMap" i have to put "button1": "button1","button2":"button2"...."buttonn":"buttonn"

if dynamic button count is 5 i have to create "button1":"button1"....."button5":"button5" and assign into




Help me the same.

Regards,
Sridhar.R
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic