asp.net.ph

Skip Navigation Links

prompt Method

DHTML Methods


Displays a Prompt dialog box with a message and an input field.

Syntax

vTextData = window.prompt ( [ sMessage ] 
   [ , sDefaultValue ] ) 
Parameters

sMessage Optional. String specifying the message to display in the dialog box. By default, this parameter is set to "".
sDefaultValue Optional. String specifying the default value of the input field. By default, this parameter is set to "undefined".

Return Value

String or Integer. Returns the value typed in by the user.

Remarks

The title of the prompt dialog box cannot be changed.

Example

The following script will display a simple Prompt dialog box and store the user's input to a variable named what, which can then be used to trigger another function.

<script language="JavaScript">
function promptSearch ( ) {
   what = prompt ( "What will you search for?", 
      "Type text to search here" );
   doSearch ( what );
}
</script>

 Show me 

Applies To

window

See Also

alert, confirm



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note