I want to add dynamic options to a SweetAlert2 input type select that looks like this:
swal({
title: 'Select Ukraine',
input: 'select',
inputOptions: {
'SRB': 'Serbia',
'UKR': 'Ukraine',
'HRV': 'Croatia'
},
inputPlaceholder: 'Select country',
showCancelButton: true,
inputValidator: function(value) {
return new Promise(function(resolve, reject) {
if (value === 'UKR') {
resolve();
} else {
reject('You need to select Ukraine :)');
}
});
}
}).then(function(result) {
swal({
type: 'success',
html: 'You selected: ' + result
});
})
Instead of those 3 countries I want to add my own options which are saved in an object. How can I do that using javascript?
var savedObject = {'value_1': 'name_1', 'value_2': 'name_2', 'value_3': 'name_3'}
, isn't it ? – Prelate{'SRB': 'Serbia', 'UKR': 'Ukraine', 'HRV': 'Croatia'}
tosavedObject
and this would works – Prelate