This the code for alerting some value:
alert('Click the OK button Now !');
So now i want to check whether the OK button is clicked or not.
How can I do this using this JavaScript?
Confirm could work:
var r=confirm("Click the OK button now!");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
Confirm HAS to have an OK and Cancel button. If you only want one button, you should either use the alert() method (which doesn't tell you if the OK was clicked) or you should look into something like the jQueryUI Dialog control.
The jQueryUI dialog is a bit more complicated because you need to include some extra JavaScript libraries and do a bit of extra wiring up to get it to work. There are a lot of examples to follow here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With