FANDOM



DescriptionEdit

Opens a dialog prompting the user for input. The user has the option to input information and either click OK or Cancel. Concel returns false as well as leaving the default information in the input box unchanged.

SyntaxEdit

prompt(param1, param2)


ParametersEdit

  • param1 (optional) string used as the dialogs message.
  • param2 (optional) the default string which is used to auto-populate the input field.


ExampleEdit

Prompt-ex01

prompt("what is your name?", "Bob");

RESULT: A dialog appears asking the user, "what is your name?" with the name "Bob" already in the input field.

prompt("What is your name?", "");

RESULT: A dialog appears asking the user, "what is your name?" no information is pregenerated in the input field.

var yourName = prompt("What is your name?", "");

RESULT: A dialog appears asking the user, "what is your name?" no information is pre-generated in the input field. If any text is entered, it is stored in the variable "yourName" Otherwise false is stored into "yourName"

NotesEdit

Although the second param2 is not needed, you should include an empty string.