I was looking for a picklist template in JavaScript and came across this code.
Which has the following code to parse through a from what I am assuming is a jQuery object array.
var val = {
01: {id: 01, text: 'test2'},
02: {id: 02, text: 'test3'},
03: {id: 03, text: 'test2'},
};
var pick = $("#pickList").pickList({data: val});
$("#getSelected").click(function () {
console.log(pick.getValues(val));
alert(pick.getValues());
});
Where the #pickList is a function which populates data onto a form.
Now when I run this using the button "#getSelected" , I can see in Chrome developer options that it is fetching the data from the form but in some sort of an key value pair.
Now, When I try to alert(pick.getValues());
I get an alert with [object Object] and not the value inside the array.
Can someone help me to know how to parse the array so that I can get the value of the "text"
Below is a screenshot of the Chrome dev console. Screenshot of chrome dev options
alert(pick.getValues());useconsole.log(pick.getValues());and see the console output in your dev console.alert(JSON.stringify(pick.getValues()))