<initial>
Declares initial logic upon entry into a (mixed-initiative) form.
Syntax
<initial
name="string"
expr="js_expression"
cond="js_expression"
>
Child Elements
</initial>
Description
Control item that controls the initial interaction in a mixed initiative form. An <initial> element can request user input or perform other non-interactive initialization tasks at the beginning of a mixed initiative form. As with all form items, an <initial>'s form-item variable must have a value of undefined in order to be visited.
If any of the form's fields are filled as a result of user input, the interpreter sets all <initial> form-item variables to true before performing any <filled> actions. After that, it will request user input in a "directed mode" based on the prompts associated with the fields that are still unfilled.
| Attribute |
Description |
name
|
Name of form-item variable, which may not be a JavaScript reserved keyword. Optional (default is an unusable internal name).
The form-item variable has dialog (form) scope; its name must be unique among all VoiceXML and JavaScript variables within the form's scope.
Generally, you use this attribute only if you want to control <initial> execution explicitly.
|
expr
|
JavaScript expression that assigns the initial value of the form-item variable. Optional (default is undefined).
If you set the form-item variable to a value other than undefined, you'll need to clear it before the <initial> element can execute. Note that you need to give the form-item variable a name if you want to clear it separately from other form-item variables.
|
cond
|
JavaScript boolean expression that must also evaluate to true for the <initial> element to execute. Optional (default is true).
If not specified, the value of the form-item variable alone determines whether or not the <initial> element can execute.
|
|
|
Tip:
|
| | If a JavaScript expression contains any of the characters "<", ">", or "&", that character must be replaced with the corresponding escape sequence "<", ">", or "&". For more information, see JavaScript Quick Reference. |
|
Usage
Exceptions
error.semantic - Thrown if no grammars are active.
See Also
Examples
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="foo">
<grammar src="foo.grammar#Main"/>
<nomatch> Okay, let me ask you the questions separately. <reprompt/>
<assign name="selection" expr="true"/>
</nomatch>
<initial name="selection">
Please say how many apples or oranges you want.
</initial>
<field name="fruit">
<grammar src="foo.grammar#Fruit"/>
Do you want apples or oranges?
</field>
<field name="quantity">
<grammar src="foo.grammar#Quantity"/>
How many <value expr="fruit"/> do you want?
</field>
<block>
<prompt>
You said that you wanted <value expr="quantity"/>
<value expr="fruit"/>.
</prompt>
</block>
</form>
</vxml>
[Show Frames] [FIRST] [PREVIOUS] [NEXT]