Hello,
I created one field with select2 as below:
jQuery(document).ready(function ($) {
var ajaxurl = '/wp-admin/admin-ajax.php';
$.ajax({
url: ajaxurl,
data: {
action: 'multiselect', // This is our PHP function below
},
success: function (response) {
var dataarray = JSON.parse(response);
$('.js-example-basic-multiple').find('option').remove();
$.each(dataarray, function (key, value) {
$('.js-example-basic-multiple').append($('<option>', { value: value [0]}).text(value[1]));
});
console.log(response);
},
error: function (xhr, status, error) {
var result = JSON.parse(xhr.responseText);
window.alert('Status: ' + status + '. Return: ' + result + '. Error: ' + error);
}
});
});
Is there any way to make selected value clickable to display all value related to selected ID?
Thank you