首页  >  问答  >  正文

SweetAlert2 - 保存输入值到文本字段后返回的是"

i'm trying to make pop-up window when my form loads. and when you enter ID number in the pop-up window, it stores in the text-field in the form. enter image description here - this is where u put the ID Number. enter image description here - and this is where i want the value to be saved. I'm using AgilePoint - and inside i insert js code and sweetalert2. this is the code i'm trying to do:

eformEvents.onFormLoadComplete = function()

{Swal.fire({ //rtl:true

title: 'title', html: '<p>hello</p>', icon:info, input:'text', inputLabel: 'Enter ID'

})

.then(inputValue) => {document.getElementById("Eid").Value = inputValue}

Swal.fire('Success')

})}

我正在尝试在我的表单加载时弹出窗口。 当您在弹出窗口中输入ID号码时,它将存储在表单中的文本字段中。 输入图像说明 - 这是您放置ID号码的位置。 输入图像说明 - 这是我想要保存值的位置。 我正在使用AgilePoint - 在其中插入js代码和sweetalert2。 这是我尝试做的代码:

eformEvents.onFormLoadComplete = function()

{Swal.fire({ //rtl:true

title: 'title', html: '<p>hello</p>', icon:info, input:'text', inputLabel: 'Enter ID'

})

.then(inputValue) => {document.getElementById("Eid").Value = inputValue}

Swal.fire('Success')

})}

P粉445750942P粉445750942399 天前441

全部回复(1)我来回复

  • P粉211273535

    P粉2112735352023-09-17 15:22:37

    SweetAlert的then块将接收一个对象。您需要从该对象中选择value属性。

    尝试像下面这样的东西。

    Swal.fire({
      title: '标题', html: '<p>你好</p>', input:'text', inputLabel: '输入ID',  
    }).then(({value}) => {
      document.getElementById("Eid").Value = value
      Swal.fire('成功')
    })

    回复
    0
  • 取消回复