0
votes

I will be pulling values from a table, and the select2 will be populated with ajax in a form. I will not have the ID numbers (although the ID numbers could be searchable). How do I either find the ID numbers that select2 is initialized with, or set the select2 using the .text only value without using .val?s

select2 will set the value like this;

$('#nwco').val('2');

select2 will not select2 will set the value like this;

$('#nwco').text('Item 1');
1

1 Answers

0
votes

Try to Save the select2 values inside a hidden element also and then get values from that hidden element. Note that if you change anything on select2 update the hidden element also. I think this will help you to solve your problem.