I'm using this "sweet alert 2", I I need of multiple checkbox, In documentation there is 'input-radio' option with multiple choice, but only single choice for checkbox option.
Is there possibily to use this script with checkbox multiple choice?
swal({
title: 'Select color',
input: 'radio',
inputOptions: {
'#ff0000': 'Red',
'#00ff00': 'Green',
'#0000ff': 'Blue'
}
})
thanks
It is not supported per se, but you can easily achieve that by writing your own HTML:
swal({
title: 'Multiple checkbox inputs',
html: `
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checkbox1">
<label class="form-check-label" for="checkbox1">
checkbox1
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checkbox2">
<label class="form-check-label" for="checkbox2">
checkbox2
</label>
</div>
`,
focusConfirm: false,
preConfirm: () => {
console.log('Is checkbox1 checked:' + document.getElementById('checkbox1').checked);
console.log('Is checkbox2 checked:' + document.getElementById('checkbox2').checked);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With