Thursday, 2 June 2011

WMLScript Dialogs Library


WMLScript Dialogs Library
The Dialogs library contains functions that displays alert messages.
WMLScript Dialogs Library Functions
Function
Description
Displays a message and waits for a confirmation
Displays a message and waits for an answer
Displays a question and waits for an input

1)        WMLScript alert() Function

The alert() function displays a message, waits for a confirmation, and then returns an empty string.

Syntax

n = Dialogs.alert(message)

Part
Description
N
The empty string returned from the function
Message
A string containing the message

Example

var a = Dialogs.alert("The value must be numeric!");

Result

a = ""

2)        WMLScript confirm() Function

The confirm() function displays a message, waits for an answer, and then returns a boolean value depending on which answer the user selected. If the user selected the ok value the return value is true, and if the user selected the cancel value the return value is false.

Syntax

n = Dialogs.confirm(message, ok, cancel)

Part
Description
N
The Boolean value returned from the function
Message
A string containing the message
Ok
A string containing the OK text
Cancel
A string containing the CANCEL text

Example

var a = Dialogs.confirm("Exit?","Yes","No");

Result

a = true (if "Yes" is selected)
a = false (if "No" is selected)

3)        WMLScript prompt() Function

The prompt() function displays a message and waits for an input. The second parameter is a default input, that will be returned if the user does not enter a value. This function returns the user input or the default value.

Syntax

n = Dialogs.prompt(message, defaultinput)

Part
Description
n
The string returned from the function
message
A string containing the message (question)
defaultinput
A string containing the default input (answer)

Example

var a = Dialogs.prompt("Enter a number:","3");

Result

a = "5" (if the user entered the value 5)
a = "3" (if the user did not enter a value)

No comments:

Post a Comment