Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
how to raise an event after 'ok' click in an alert box ?

not confirm i need alert
Posted
Updated 16-Apr-14 23:20pm
v2

Just put your code after you call the alert function:
JavaScript
alert('Your text here');
// the code that you put here will be executed after the user clicks OK in the alert box


Or, if you mean that you want a box with Yes and No options, then use the confirm function:
C#
if (confirm('Your text here')) {
    // user clicked on Yes
}
else {
    // user clicked on No
}
 
Share this answer
 
v2
Comments
Member 10690248 5-Apr-14 9:10am    
tnx
Thomas Daniels 5-Apr-14 10:17am    
You're welcome!
Member 15897956 13-Feb-23 3:20am    
Normally this doesn't work and you have to repeat the close line twice.
JavaScript
function myFunction()
{
var x;
var r= confirm("Press a button!");
if (r==true)
  {
  x="You pressed OK!";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}


---------
HTML
---------

HTML
<button onclick="myFunction()">Press Me</button>
<p id="demo"></p>
 
Share this answer
 
Comments
computerblade 25-Jan-22 7:51am    
thank you!
XML
alert('EnterBookCode');
             $(document.activeElement).bind('click', function () {
          document.getElementById("<%=txtsearch.ClientID %>").focus();
      });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900