Ich verwende dieses Plugin für Bootstrap 3 https://github.com/Geodan/DualListBox, und dieses Beispiel https://jsfiddle.net/hh2zrt82/ Ich versuche, eine ausgewählte Werte zu bekommen, aber ich kann nicht, wie kann ich einen ausgewählten Werte zu bekommen. Verwerten Sie Ihre Hilfe.Bootstrap Dualistbox wie Werte erhalten
var data = [
{
"id": 56,
"countryList_id": 10,
"port_iso": "India-pok"
},
{
"id": 57,
"countryList_id": 10,
"port_iso": "India-nmp"
},
{
"id": 58,
"countryList_id": 10,
"port_iso": "India-cop"
},
{
"id": 61,
"countryList_id": 2,
"port_iso": "Bangladesh-dhp"
},
{
"id": 62,
"countryList_id": 2,
"port_iso": "Bangladesh-brp"
},
{
"id": 63,
"countryList_id": 3,
"port_iso": "Singapore-pos"
},
{
"id": 64,
"countryList_id": 3,
"port_iso": "Singapore-SIN"
},
{
"id": 65,
"countryList_id": 3,
"port_iso": "Singapore-zxczx"
},
{
"id": 66,
"countryList_id": 2,
"port_iso": "Bangladesh-qewrqwe"
},
{
"id": 67,
"countryList_id": 3,
"port_iso": "Singapore-erer"
},
{
"id": 68,
"countryList_id": 3,
"port_iso": "Singapore-SIN"
}
];
var port_ids = [65,66,67];
var options = '';
for (var i = 0; i < data.length; i++) {
var a = 1;
for (var j = 0; j < port_ids.length; j++) {
// Appending "selected" attribute to the values which are already selected
if (port_ids[j] == data[i]["id"]) {
options += '<option value="' + data[i]["id"] + '" selected="selected">' + data[i]["port_iso"] + '</option>';
a = 0;
}
}
if (a == 1) {
options += '<option value="' + data[i]["id"] + '">' + data[i]["port_iso"] + '</option>';
}
}
$("select#country-of-operation-edit").empty().append(options);
$("#country-of-operation-edit").DualListBox();