value element
VoiceXML 2.0
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
None.

Children
None.

Remarks
The value element lets you insert the contents of a variable into an audio, log, 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>


[24]7 Inc.| Terms of Service| Privacy Policy| General Disclaimers