【问题标题】:Sweetalert2 can I compare value from range input?Sweetalert2 我可以比较范围输入的值吗?
【发布时间】:2020-10-10 20:19:03
【问题描述】:

我有一个来自 Sweetalert2 的范围输入,它显示了从 50 到 4000 的多个值,在这种情况下,我想将用户输入的值与条件中已设置的值进行比较,以便代码向用户需要的值。该代码仅在确认用户选择的高度之前有效。

<script>
  Swal.queue([{
  title: 'Hemoglobine/Height Simple Calculator',
  confirmButtonText: 'Next &rarr;',
  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


    【解决方案1】:

    您是否尝试将数组更改为 0?

    if (result.value[0] > 1000)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-09
      • 1970-01-01
      • 2015-05-05
      • 2010-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多