The prompt box allows the user to enter information. The benefits of using a prompt is fairly limited and the use of forms would be preferred (from a user perspective). However, it exists and you are here to find out how it works.
The prompt box title text cannot be changed, the same applies to button text. You can have 2 lines of text using \n where the new line starts (please note that opera up to v7 will only display 1 line of text)
The text entry field is similar to a form input type="text" The 2 buttons are OK and Cancel. The value returned is either the text entered or null.
For demo purposes all example will output to an alert box - but on your pages there is nothing to stop you from updating incorrect form fields by providing the prompt dialog
The syntax for the prompt is
prompt("your message",""); (script tags omitted)
"your message","" the ,"" holds the default text value "" = empty.
Let's look at an example. Open a prompt
Here's the code. (written longhand for clarity)
<script language="JavaScript" type="text/javascript">Here is another example
The code (written longhand for clarity)
<script language="JavaScript" type="text/javascript">So there you have it, 2 examples of prompt box usage. How you use the prompt obviously depends on your requirements but whatever the use, the examples above show how to use the prompt in a useful way.
Let's move on to the confirm box