<form>
Presents information and collects spoken input from users. A <form> may contain:
- Form items—elements that are visited in the main loop of the form interpretation algorithm. Form items may be input items that can be filled with user input (<block>, <option>, <record>, <subdialog>, or <transfer>), or control items that carry out instructions (<block>, <initial>).
- Declarations of non-form item variables.
- Event handlers.
- "Filled" actions—blocks of procedural logic that execute when certain combinations of input item variables are assigned.
See the VoiceXML 2.1 specification for more information.
Attributes
This section describes the attributes you can set for this element.
Name |
Data type |
Default |
---|---|---|
ID |
optional |
|
(document | dialog) |
dialog |
id
The id attribute assigns a unique identifier to the <form> element that lets it be referenced in other elements. In the following example, the <goto> element transfers control to the <form> element having id attribute mainmenu.
<goto next="#mainmenu"/>
The id attribute can be used in any URL to specify that dialog execution starts at a designated <form> element.
scope
The scope attribute allows you to set the scope of the grammar contained within the <form> element. You can set the scope in one of the following ways:
- dialog (default)—The grammar is active only in the current form.
- document—The grammar is active throughout the current document. If the current document is the application root document, then the <form> grammar will be active throughout your application.
Children
- <block>
- <catch>
- <data>
- <error>
- <field>
- <filled>
- <grammar>
- <help>
- <initial>
- <link>
- <noinput>
- <nomatch>
- <property>
- <record>
- <script>
- <subdialog>
- <transfer>
- <var>
Parents
Sample code
<form id="weather_info">
<grammar src="../grammars/cityandstate.grxml"/>
<initial name="start">
<prompt> For what city and state would you like the
weather?</prompt>
</initial>
<field name="state">
<prompt> What state? </prompt>
</field>
<field>
<prompt> Please say the city in <value expr="state"/> for
which you want the weather.
</prompt>
</field>
<filled>
<submit next="/servlet/weather" namelist="city state"/>
</filled>
</form>