• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamically set dropdown box values from given parameters and JSON response

 
Greenhorn
Posts: 8
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Could use some help.

Let's say that GET request (http://localhost:8080/blablabla/rest/ingredientgroups), would return something like below:




Currently I use something like below to set values to a dropdown box element with id #ingredientGroupNameSelect:




I'm trying to create a more general method (that I would like to re-use where possible) which would take in some parameters and then valuate certain dropdown box
I have come up with something as below but I'm falling a bit short....



I'm struggling with the syntax to use variables valueId and valueName

I'm still very new to this.... Sure could use some help.

Much appreciated. TA.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the parameters valueId and valueName supposed to be? You are obtaining the results using Ajax within the function, why would you pass any data to that function?

EDIT: ok, now I see what you are trying to do:

result[index][valueId]
 
Rain Tüür
Greenhorn
Posts: 8
Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:What are the parameters valueId and valueName supposed to be? You are obtaining the results using Ajax within the function, why would you pass any data to that function?

EDIT: ok, now I see what you are trying to do:

result[index][valueId]



beautiful....
I was trying with result[index].[valueId]

Thank you sooo much!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic