Closed HadiAkmal closed 6 years ago
its a promise ... so after doing something like
swal("Write something here:", { content: 'input', }) .then((value) => { swal('You typed: ${value}'); });
Know more about it here https://sweetalert.js.org/guides/#advanced-examples
@girishpatil
I can get the value if it's single input but I have 2 input field. When I tested it, the value
output is true
and I'm not getting the data that I keyin the 2 field.
I found example at "https://sweetalert2.github.io/"
const {value: formValues} = await swal({ title: 'Multiple inputs', html: '<input id="swal-input1" class="swal2-input">' + '<input id="swal-input2" class="swal2-input">', focusConfirm: false, preConfirm: () => { return [ $('#swal-input1').val(), $('#swal-input2').val()] } }) if (formValues) { swal(JSON.stringify(formValues)) }
@g4b0-88 SweetAlert2 is a different project, it's repo is https://github.com/sweetalert2/sweetalert2
@HadiAkmal Take a look at https://sweetalert.js.org/guides/#using-dom-nodes-as-content. You'll have to use swal.setActionValue
if you want the promise to resolve a custom value (in this case, an array of strings seems right).
I'm using
content
with multipleinput
element:msg.innerHTML = '<input type="text" name="FirstName" value="Abu"> <input type="text" name="LastName" value="Ali"> test <b>123<b>';
Result:
My question is, how do I retrieve the input value upon save?
Thanks in advance.