I'm trying to build a basic pop-up form stepper using SweetAlert which allows the user to provide a report name, description and a comment, then send it to the server to save the values in storage.
The issue I'm having is that the textarea
option doesn't return me the value, only true
so I cannot pass the value to the back-end.
This is what I have so far:
swal({
text: 'What would you like to name this report?',
html: true,
content: {
element: 'input',
},
buttons: 'Next'
})
.then((value) => {
if (!value) throw null;
let name = value;
swal({
text: 'Give this report a description',
content: {
element: 'textarea',
},
buttons: 'Next'
}).then((value) => {
if (!value) throw null;
let description = value;
swal({
text: 'Add a comment?',
content: {
element: 'textarea',
},
buttons: 'Publish'
})
.then((value) => {
let comment = value;
console.log(name) // Returns the correct value
console.log(description) // Returns true
console.log(comment) // Returns true
})
.catch(error => console.log(error))
})
.catch(error => console.log(error))
})
How can I get the value for the textarea here?