Javascript Prompt

Javascript Prompt Box

Prompt uses a text field to enter a value. It also has 'OK' and 'CANCEL' buttons.

The text input to the prompt can be stored in a variable.

Let us look at the example that simply displays a prompt box and diplays an alert box with a message. The message displayed in the alert box will depen upn the user input in the prompt box.

<script type="text/javascript">
Example Prompt Box
var name = prompt("What is your name?", "Type your name here");
alert("Your name is: "+name)


You can try this example online at the link below, which will open in a new window.

Javascript Prompt Box - Example

If you have any questions, you my like to post questions in Forum , where someone knowledgeble will try to answer your questions.