Ok Cancel prompt javaScript
This dialog box is displayed using a method called prompt() which takes two parameters (i) A label which you want to display in the text box (ii) A default string to display in the text box.
This dialog box with two buttons: OK and Cancel. If the user clicks on OK button the window method prompt() will return entered value from the text box. If the user clicks on the Cancel button the window method prompt() returns null.
<html> <head> <script> function functionP() { // prompt(<prompt title>, <defaula value>); var retVal = prompt("Enter anything: ", "123"); alert("You have entered : " + retVal ); // displays input value in alertbox } </script> </head> <body> <button value="Back" onclick="functionP()"> Click Here </button> </body> </html>