Plum DEV Documentation
voicexml:tags:if

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

voicexml:tags:if [2014/05/29 15:35]
jennifer meta description
voicexml:tags:if [2019/09/17 12:29]
Line 1: Line 1:
-{{description>​‹if› VoiceXML tag details, attributes and VXML code example.}} 
-=====<​if>​===== 
- 
-The <if> element is used for conditional logic. It has optional <​else>​ and <​elseif>​ elements. 
-====Attributes==== 
-| cond | An ECMAScript expression to evaluate. | 
- 
-====Notes==== 
- 
-Note that the <​else>​ and <​elseif>​ tags both must contain a trailing forward slash to terminate. ​ 
- 
-Correct example: 
-<​code>​ 
-<if cond="​number==5">​ 
-  <!-- do something --> 
-<elseif cond="​number==2"/>​ 
-  <!-- do something else --> 
-<​else/>​ 
-  <!-- do something for all other cases --> 
-</if> 
-</​code>​ 
- 
-Incorrect example: 
-<​code>​ 
-<if cond="​number==5">​ 
-  <!-- do something --> 
-<elseif cond="​number==2">​ 
-  <!-- this won't work since we left off the / --> 
-<​else>​ 
-  <!-- this also won't work since we left off the / --> 
-</if> 
-</​code>​ 
- 
-====Example==== 
-<​code>​ 
-<?xml version="​1.0"?>​ 
-<vxml version="​2.0">​ 
-  <​form>​ 
-    <field name="​myprompt"​ type="​digits">​ 
-      <​prompt>​ 
-        Say the magic number between 1 and 9. 
-      </​prompt>​ 
-      <​filled>​ 
-        <!-- The "​cond"​ attribute within an "​if"​ tag --> 
-        <!-- should contain a boolean ECMAscript expression. --> 
-        <if cond="​myprompt==5">​ 
-          <​prompt>​ 
-            You guessed correctly! 
-          </​prompt>​ 
-        <elseif cond="​myprompt==4 || myprompt==6"/>​ 
-          <​prompt>​ 
-            You're close. Try again. 
-          </​prompt>​ 
-          <clear namelist="​myprompt"/>​ 
-        <​else/>​ 
-          <​prompt>​ 
-            Try again. 
-          </​prompt>​ 
-          <clear namelist="​myprompt"/>​ 
-        </if> 
-      </​filled>​ 
-    </​field>​ 
-  </​form>​ 
-</​vxml>​ 
-</​code>​ 
- 
-The output of the above script would be: 
- 
-Computer: Say the magic number between one and nine. \\ 
-Human: Three. \\ 
-Computer: Try again. Say the magic number between one and nine. \\ 
-Human: Six. \\ 
-Computer: You're close. Try again. Say the magic number between one and nine. \\ 
-Human: Five. \\ 
-Computer: You guessed correctly! 
- 
- 
-====Child Tags==== 
- 
-[[voicexml:​tags:​audio|<​audio>​]],​ [[voicexml:​tags:​assign|<​assign>​]],​ [[voicexml:​tags:​clear|<​clear>​]],​ [[voicexml:​tags:​data|<​data>​]],​ [[voicexml:​tags:​disconnect|<​disconnect>​]],​ [[voicexml:​tags:​else|<​else>​]],​ [[voicexml:​tags:​elseif|<​elseif>​]],​ [[voicexml:​tags:​enumerate|<​enumerate>​]],​ [[voicexml:​tags:​exit|<​exit>​]],​ [[voicexml:​tags:​foreach|<​foreach>​]],​ [[voicexml:​tags:​goto|<​goto>​]],​ [[voicexml:​tags:​if|<​if>​]],​ [[voicexml:​tags:​log|<​log>​]],​ [[voicexml:​tags:​prompt|<​prompt>​]],​ [[voicexml:​tags:​reprompt|<​reprompt>​]],​ [[voicexml:​tags:​return|<​return>​]],​ [[voicexml:​tags:​script|<​script>​]],​ [[voicexml:​tags:​submit|<​submit>​]],​ [[voicexml:​tags:​throw|<​throw>​]],​ [[voicexml:​tags:​value|<​value>​]],​ [[voicexml:​tags:​var|<​var>​]] 
- 
- 
-====Parent Tags==== 
- 
-[[voicexml:​tags:​block|<​block>​]],​ [[voicexml:​tags:​catch|<​catch>​]],​ [[voicexml:​tags:​error|<​error>​]],​ [[voicexml:​tags:​filled|<​filled>​]],​ [[voicexml:​tags:​foreach|<​foreach>​]],​ [[voicexml:​tags:​help|<​help>​]],​ [[voicexml:​tags:​if|<​if>​]],​ [[voicexml:​tags:​noinput|<​noinput>​]],​ [[voicexml:​tags:​nomatch|<​nomatch>​]]