Javascript alert popup with two buttons OK / Cancel or Yes / No

How can I add another button to javascript alert popup window, to have two buttons with values OK / Cancel or Yes / No ?
0
give a positive ratinggive a negative rating
08 Dec 2020 at 04:44 PM
Hi,

To get javascript "alert like" box with OK and Cancel button, you have to use confirm() function. It works similar to alert() function, but it displays two buttons with possibility to create positive and negative condition:

<script>
var val = confirm("Type your text here.");
if (val == true) {
alert("You pressed OK.");
} else {
alert("You pressed Cancel.");
}
</script>

0
give a positive ratinggive a negative rating
09 Dec 2020 at 09:54 AM
Tim
Share on FacebookShare on TwitterShare on LinkedInSend email
x
x
2024 AnswerTabsTermsContact us