Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Javascript: dynamic query/condition build help

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic