【发布时间】:2020-10-10 20:19:03
【问题描述】:
我有一个来自 Sweetalert2 的范围输入,它显示了从 50 到 4000 的多个值,在这种情况下,我想将用户输入的值与条件中已设置的值进行比较,以便代码向用户需要的值。该代码仅在确认用户选择的高度之前有效。
<script>
Swal.queue([{
title: 'Hemoglobine/Height Simple Calculator',
confirmButtonText: 'Next →',
showCancelButton: true,
text: 'what is the estimated height??',
showLoaderOnConfirm: true,
input: 'range',
inputAttributes: {
min: 50,
max: 4000,
step: 50
},
inputValue: 50,
preConfirm: function(value) {
Swal.insertQueueStep({
type: 'question',
title: 'Hemoglobine/Height Simple Calculator',
confirmButtonText: 'Confirm',
showCancelButton: true,
text: 'Your value is ' + value + ' Height_above_sea_level?',
})
},
allowOutsideClick: () => !Swal.isLoading()
}]).then((result) => {
if (result.value[1] > 1000) {
Swal.fire({
type: 'success',
title: 'Success!',
text: 'The entered values must be reevaluated, subtract -0.2 gr / dL from the hemoglobin values for the new evaluation'
})
}
})
if (result.value[1] > 1500) {
Swal.fire('The entered values must be reevaluated, subtract -0.5 gr / dL from the hemoglobin values for the new evaluation')
}
【问题讨论】:
标签: javascript alert sweetalert2