I need assistance in creating a simple pop-up form stepper using SweetAlert. The purpose is to allow users to input a report name, description, and comment, then send that data to the server for storage.
My challenge lies in retrieving the value from the textarea
option, as it only returns true
instead of the actual user input.
This is the current code snippet I am working with:
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))
})
I am unsure how to retrieve the user-input value for the textarea. Any suggestions?