Set Id to select options. (Drop Down Element Id's)
Set Id to select options. (Drop Down Element Id's)
Hi, I have a dynamic drop down list being populated from a query. I am struggling to find a way to assign id='' to each option element. When an item is selected i need to use $(#+'the selected id').on('click' to preform a function. How do i assign id's to the option elements.
'''js
aStateList[x] = { 'label': '+YdataArray[x]['RegYear']+'', 'value':'+YdataArray[x]['RegYear']+'','Id':''+YdataArray[x]['RegYear']};
$('#'+YdataArray[x]['RegYear']).on('click', function(){
// console.log('Selected');
})
}
'''
This question has accepted answers - jump to:
This discussion has been closed.
Answers
This Worked For me.
That looks correct. The other way to get the select element is via the
field().input()
method.Allan