[wd_asp elements=’search’ ratio=’100%’ id=1]

Sweet Alert with textbox edit

16th November 2020

Jquery - Tricks

jquery icon

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


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