ZVON > References > VoiceXML Reference
Element:script
Attributes: | caching | charset | fetchhint | fetchtimeout | src |
Parents: | block | catch | error | filled | help | if | noinput | nomatch | vxml |
Description:

Go to Standard

Examples:


<vxml version="1.0">
     <script> function factorial(n) { return (n <= 1)? 1 : n * factorial(n-1); } </script>
     <form id="form">
          <field name="fact" type="number">
               <prompt> Tell me a number and I'll tell you its factorial. </prompt>
               <filled>
                    <prompt>
                         <value expr="fact"/> factorial is
                         <value expr="factorial(fact)"/>
                    </prompt>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <form>
          <var name="hours"/>
          <var name="minutes"/>
          <var name="seconds"/>
          <block>
               <script> var d = new Date(); hours = d.getHours(); minutes = d.getMinutes(); seconds = d.getSeconds(); </script>
          </block>
          <field name="hear_another" type="boolean">
               <prompt> The time is
                    <value expr="hours"/> hours,
                    <value expr="minutes"/> minutes, and
                    <value expr="seconds"/> seconds.
               </prompt>
               <prompt>Do you want to hear another time?</prompt>
               <filled>
                    <if cond="hear_another">
                         <clear/>
                    </if>
               </filled>
          </field>
     </form>
</vxml>