After many hours of trying Sweet Alert, I have finally managed to add a textbox, and edit a variable. The magic part was inputValue: keywordid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
var keywordid = $(this).attr('id'); Swal.fire({ title: "Sweet Alert Text Box", text: "Write something interesting:", input: 'text', inputValue: keywordid, showCancelButton: true }).then((result) => { if (result.value) { alert("Result: " +result.value); } }); |
Another version of this is the text area input with sweet alert
This is supposed to be the way of adding text input but I never managed to make it work correctly.
https://sweetalert2.github.io/#input-radio
And here is some more ways that seem to do much of the job
https://www.manongdao.com/article-2170424.html