assign

Assigns a value to a variable.

<assign 
expr = "ECMAScript_Expression"
name = "string"
/>

expr

Required. The value to assign to the variable.

name

Required. The name of the variable.

Before using the assign element on a variable, you must first declare it using the var element.

If this value is a string, you must enclose it in single quotation marks.

The following example declares four variables at document scope, uses the assign element to calculate the cost of a product, and plays the information back to the user in a sentence.


<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
   <!--document-scoped variables -->
   <var name="product" expr="'windbreaker'"/>
   <var name="retail_price" expr="135"/> 
   <var name="discount" expr=".35"/> 
   <var name="cost"/>  

   <form id="check_price">
      <block>  
         <assign name="cost" expr="retail_price*discount"/>  
         <prompt>With a <value expr="discount*100"/> percent discount, 
         the cost of the <value expr="product"/> is <value expr="cost"/></prompt>  
      </block> 
   </form>
</vxml>

Community Additions

ADD
Show: