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
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>

Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us