Dialog.prompt()
Just like Dialog.alert, this function is intended as a replacement
for JavaScript’s buit-in prompt() function.
However, since this dialog is asynchronous, i.e. the program flow does not wait until the user
closes the dialog, you need to use the onConfirm and onCancel-callbacks for any
code you want to perform after the user dismisses the dialog.
Once you are at it: you can also pass a parameter called input to pre-define the value
that should appear in the input field. If you do not provide any value here, the field will be initially
empty. One warning though: if you pass a null value here, the input field will
not appear at all!
To get the actual value of the text field (e.g. in the onConfirm callback),
you would need to use the dialog’s getText() function, like in the following
example:
Dialog.prompt('What was your name again?', {
input: 'anonymous',
onConfirm: function(dlg) {
var name = dlg.getText();
alert('Hello '+name);
},
onCancel: function(dlg) {
alert('You cancelled.');
}
});
For more information and examples, please also see Dialog.alert and Dialog.confirm.