PHP onclick confirm to Sweet Alert 2 confirmation


I need your help here please.I have a button which is echoed by a PHP file to a HTML file. When the button is clicked it uses window confirm() method but I want to use a sweet alert 2 modal to be displayed with yes or no option in the HTML file.

Does anyone have any idea how I can make this work?

PHP echo:

$row['handler'] = "".$GLOBALS['_LANG']['cancel'].  "";  

Do I need to add the script to a external file and call it inside PHP or there is better way to do this ?


I have just modified your code.

$row['handler'] = ''.$GLOBALS['_LANG']['cancel'].   '';  

And your javascript function will looks like this

function confirmation(text