<elseif>
Conditional logic used within <if>. Specifies code to be executed only when the cond attribute of the <if> element evaluates to false and the cond expression of the <elseif> evaluates to true. Each <if> element can contain one or more <elseif> statements.
Attributes
This section describes the attributes you can set for this element.
|
Name |
Data type |
Default |
|---|---|---|
|
CDATA |
optional |
cond
The cond attribute specifies an ECMA expression which will be evaluated as a Boolean. If the expression evaluates to TRUE, then the statement associated with the <elseif> element is executed.
In the following example, the elseif statement determines whether the caller requested a reservation. If a reservation was requested, control is transferred to the reservations.vxml document:
<if cond="main_menu == ‘delivery’">
<goto next="identification.vxml" />
<elseif cond="main_menu == ‘reservations’" />
<goto next="reservations.vxml" />
</if>
Children
None.
Parents
Sample code
<vxml>
<form>
<field name="grammar_or_dtmf">
<prompt>Press or say a number between 1 and 3.</prompt>
<grammar> [one two three] </grammar>
<dtmf> [dtmf-1 dtmf-2 dtmf-3] </dtmf>
<filled>
<if cond="grammar_or_dtmf == 'one'">
<prompt>you said one</prompt>
<elseif cond="grammar_or_dtmf == 'two'"/>
<prompt>you said two</prompt>
<elseif cond="grammar_or_dtmf == 'three'"/>
<prompt>you said three</prompt>
<else/>
<prompt>you pressed <value expr=
"grammar_or_dtmf.charAt(5)"/></prompt>
</if>
</filled>
</field>
</form>
</vxml>
For a VoiceXML sample demonstrating the use of the <elseif> element, see Blackjack.vxml located in the $NVP_HOME/appservice/applications/webapps/BlackJack directory.