首頁  >  問答  >  主體

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 天前439

全部回覆(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
  • 取消回覆