Below code pops up a modal in the view that user select one of the options and then shows the selected option, I also need the id of selected option. e.g I need to get “4” if user select “John”. I am not sure how can I get it
async function accept() {
const { value: student } = await Swal.fire({
input: 'select',
width: 260,
inputOptions: {
1: 'Peter',
2: 'Sam',
3: 'Tom',
4: 'John'
},
inputPlaceholder: 'Select student',
showCancelButton: true,
})
if (student) {
Swal.fire(`You selected: ${student}`)
console.log('Id: ' ?????)
}
}