How to use Window Object Prompt in JavaScript
In this article I am going to explain about window object prompt() method in JavaScript.
JavaScript Window Object Prompt() Method
JavaScript Prompt() Method use for open a dialog box that take input from user. Prompt dialog box return a string value that entered by user.
Syntax
Window.Prompt(Message,Default display text)
|
Example
<html>
<head>
<p id="tst">
</p>
<script type="text/javascript">
function myfun() {
var mm;
var name = prompt("Enter Your Name", "prabhakar");
if (name != null) {
mm = "Hello " + name;
document.getElementById("tst").innerHTML = mm;
}
}
</script>
</head>
<body>
<button onclick="myfun()">
click me</button>
</body>
</html>
|
Output
Enter value and click ok
You may also want to read these related articles: here
Ask Your Question
Got a programming related question? You may want to post your question here