Assigns a value to a variable.
<assign
expr = "PCDATA"
name = "identifier"
/>
Attribute |
Data Type |
Required? |
Default |
Description |
expr |
PCDATA |
yes |
NA |
ECMAScript expression to evaluate and assign to the named variable. |
name |
identifier |
yes |
NA |
Name of the variable. This must be a legal ECMAScript identifier. By default, the variable is resolved within the closest enclosing scope of the currently active element. To remove ambiguity, prefix the variable name with a scope name. |
You must explicitly declare a variable using a <var> element or <var> statement within a <script> element. Attempting to assign a value to an undeclared variable causes the VoiceXML Interpreter to return an error.semantic error.
<block>, <catch>, <error>, <filled>, <foreach>, <help>, <if>, <noinput>, <nomatch>
None.
<?xml version="1.0"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
<var name="number"/>
<var name="month" expr="'March'"/>
<form>
<block>
Month is <value expr="month"/>
<assign name="month" expr="'July'"/>
Now month is <value expr="month"/>
<assign name="number" expr="2*5"/>
Number is <value expr="number"/>
</block>
</form>
</vxml>