当我单击OK时,如何使用HTML属性获取选定值的值。
changeStatus(row) {
debugger;
swal({
title: 'Change Status',
text: txt,
html: '<label class=" control-label" style="margin-top: 4px;"></label><select style="margin-left: -51%;"class="swal2-select id="dropdown"><option value="Certified">Certified</option> <option value="Registered">Registered</option> <option value="Processed">Processed</option></select><br>' + '<b style="margin-left: -84%;">Remarks </b><br>' +
'<textarea id="text" class="form-control" rows="5"></textarea>',
showCancelButton: true,
}).then((result) => {
if (result.value) {
debugger;
row.Notes = document.getElementById('text'),
row.Notes = row.Notes.value;
}
});
}
答案 0 :(得分:1)
尝试一下
swal({
title: 'Select Type',
input: 'select',
inputOptions: {
'CERT': 'Certified',
'REG': 'Registered',
'PROC': 'Processed'
},
inputPlaceholder: 'Select Type',
showCancelButton: true,
inputValidator: function (value) {
return new Promise(function (resolve, reject) {
if (value === 'REG') {
resolve('');
} else {
reject('You need to select type:)');
}
})
}
}).then(function (result) {
swal({
type: 'success',
html: 'You selected: ' + result
})
});