value
value element
Evaluates and returns an ECMAScript expression.
Syntax
<value
expr = "ECMAScript_Expression"
/>
Attributes
expr |
Required. An ECMAScript expression evaluated and returned as text to the containing element. |
Parents
audio, block, catch, emphasis, enumerate, error, field, filled, foreach, help, if, initial, log element, menu, noinput, nomatch, object, p element, prompt, prosody, record, s element, say-as, subdialog, transfer, voice
Children
None.
Remarks
The value element lets you insert the contents of a variable into an audio, log element, or prompt element. When used within an audio or prompt element, the text is converted to speech.
Examples
This example picks a random card suit, plays the name of the suit to the user and writes the value of the suit to the debug log.
<?xml version="1.0"?>
<vxml version="2.1"
xmlns="http://www.w3.org/2001/vxml">
<!-- declare an array of suits -->
<var name="aSuits" expr="new Array('hearts', 'clubs', 'diamonds', 'spades')"/>
<script>
<![CDATA[
// return the name of a suit
function GetSuit()
{
var iSuit = Math.floor(Math.random()*aSuits.length);
return aSuits[iSuit];
}
]]>
</script>
<form id="get_suit">
<block>
<var name="suit" expr="GetSuit()" />
The chosen suit is <value expr="suit" />
<log>suit=<value expr="suit" /></log>
</block>
</form>
</vxml>