Home  >  Q&A  >  body text

SweetAlert2 - After saving the input value to the text field, the return value is "

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')

})}

I'm trying to popup a window when my form loads. When you enter the ID number in the popup window, it is stored in the text field in the form. Enter the image description - this is where you put the ID number. Enter the image description - this is where I want the value to be saved. I'm using AgilePoint - inserting js code and sweetalert2 in it. 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')

})}

P粉445750942P粉445750942399 days ago438

reply all(1)I'll reply

  • P粉211273535

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

    The then block of SweetAlert will receive an object. You need to select the value attribute from this object.

    Try something like below.

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

    reply
    0
  • Cancelreply