SweetAlert2 - 当我将输入值保存到文本字段中时,它返回 [object Object]

问题描述 投票:0回答:1

我正在尝试在表单加载时制作弹出窗口。 当您在弹出窗口中输入 ID 号时,它会存储在表单的文本字段中。 enter image description here - 这是您放置 ID 号的位置。 enter image description here - 这就是我想要保存该值的地方。 我正在使用 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')

})} 

javascript sweetalert2 agilepoint
1个回答
0
投票

SweetAlert then 块将接收对象。您需要从该对象中选择值属性。

尝试如下所示。

Swal.fire({
  title: 'title', html: '<p>hello</p>', input:'text', inputLabel: 'Enter ID',  
}).then(({value}) => {
  document.getElementById("Eid").Value = value
  Swal.fire('Success')
})
© www.soinside.com 2019 - 2024. All rights reserved.