×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Skippy1957
Added: Nov 25, 2016 6:56 AM
Views: 2
Tags: no tags
  1. <p>Click the button to display a confirm box.</p>
  2.  
  3. <button onClick="myFunction()">Try it</button>
  4.  
  5. <p id="demo"></p>
  6.  
  7. <script>
  8. function myFunction()
  9. {
  10. var x;
  11. var r=confirm("Press a button!");
  12. if (r==true)
  13.   {
  14.   x="You pressed OK!";
  15.   }
  16. else
  17.   {
  18.   x="You pressed Cancel!";
  19.   }
  20. document.getElementById("demo").innerHTML=x;
  21. }
  22. </script>
  23.  
  24. </body>
  25. </html>
  26.