Hey guys,
I’m stuck on this select drop-down feature on my project. So I want to load in the options for the select from a back-end api and I was able to do this with this snippet:
`var keys = Object.keys(resp.msg.cohorts);
let $dropdown = $(‘#cohortType’);
$dropdown.empty();
$.each(keys, function(index,item) {
$(‘<option></option>’)
.attr(‘value’, index)
.text(item)
.appendTo($dropdown);
});
But where I’m stuck is, when I hit the submit button once you select an option, I want to retrieve the values associated with the key (the option the user chooses). Any idea how I may approach this?
Structure of the api data:
Any suggestions is very much appreciated!