Prompt Dialog Box in JavaScript

The prompt dialog box is very useful when you want to pop-up a text box to get user input. Thus it enable you to interact with the user. The user needs to fill in the field and then click OK.

Example

<html>
<head>
<script>
	function functionP() 
	{
		var x = prompt("enter anything"); // displays prompt
		alert(x); // displays input value in alertbox
	}
</script>
</head>
<body>

	<button value="Back" onclick="functionP()">
		Click Here 
	</button>

</body>
</html>

Output