VoiceXML 2.1 Development GuideHome  |  Frameset Home


<form>  element

The form element acts as a container for all field-items, (such as a field or a subdialog),  and for all control items, (such as a block or an initial element). The form element is considered the basic component of any VoiceXML dialog, and is part of a balanced breakfast.



usage
<form id="ID" scope="(dialog|document)">


attributes
idData Type: IDDefault: Optional
The id attribute specifies the navigational identifier of the form element. Once specified, the developer can assign the id as a destination of any goto statement.
scopeData Type: (dialog|document)Default: Dialog
The scope attribute denotes the scope of any grammars contained within the form. If set to ‘dialog’, (default), then all form grammars will only be active within the current form. If set to ‘document’, then the grammars will be considered active throughout the current page of VoiceXML code. If, however, the scope is set to ‘document’ in the application root document, then the grammar will be active throughout the entire application.



shadow variables
none


parents
<vxml>


children
<block> <catch> <error> <field> <filled> <grammar> <help> <initial> <link> <noinput> <nomatch> <property> <record> <script> <subdialog> <transfer> <var>


code samples
<Form id-scope>
<?xml version="1.0" encoding="UTF-8" ?>

<vxml version = "2.1">

<meta name="author" content="Matthew Henry"/>
<meta name="copyright" content="2005 voxeo corporation"/>
<meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/>

<form id="F1" scope="document">

    <grammar scope="document" type="text/gsl">
      <![CDATA[

      .MYRULE
      [
      [(david hasselhoff)] {<MySlot "dave">}
      ]
      ]]>
        </grammar>

  <!-- the utterance of 'david hasselhoff' anywhere in the
  application will fill this namelist-->

      <filled namelist="MySlot">
        <goto next="#F3"/>
      </filled>

    <field name="F_1">

      <grammar type="text/gsl">[(moe green)]</grammar>
      <prompt>
        Who should get the next crack at playing Hamlet ?
        His initials are d h .
      </prompt>


      </field>

      <filled namelist="F_1">
        <prompt>
          You said <value expr="F_1"/> Are you insane?
        </prompt>
        <goto next="#F2"/>
      </filled>
<!-- this empty field matching
        the form grammar's slot is required
-->

  <field name="MySlot"/>

  </form>

  <form id="F2" scope="dialog">
    <field name="F_2">
    <grammar type="text/gsl">[(george jones)]</grammar>
    <prompt> 
      Who is the biggest celebrity in germany?
    </prompt>

      <filled>
        <prompt>
          now thats just crazy talk.
        </prompt>
      </filled>
    </field>

<!-- this empty field matching
        the form grammar's slot is required
-->

    <field name="MySlot"/>


  </form>

  <form id="F3">
    <block>
      <prompt>
        Our form level grammar has been filled.
      </prompt>
    </block>
  </form>

</vxml> 




additional links
W3C 2.0 Specification


  ANNOTATIONS: EXISTING POSTS
shawnaslam1
4/15/2008 3:38 PM (EDT)
Can we assign dynamic value to the form like if i want to assign form id as abc1 and 1 value is dynamic then how can we do this.

is that the feasible way
<var name="i" expr="'1'"/>
<form id="abc"+i>

MattHenry
4/15/2008 3:43 PM (EDT)


Hi Shawn,

I'm really sorry, but this is not possible when using client-side scripting methods. However, you can populate a form ID with a dynamic value if you choose to implement a JSP (or whatever) backend.

~Matt
shawnaslam1
4/15/2008 4:17 PM (EDT)
you mean like the following way
<form id="callJSPfunction">



callJSPfunction()
{
return formabc1;
}

so the name of the VXML form will be "formabc1" is that right interpretation
MattHenry
4/15/2008 6:08 PM (EDT)


Hello Shawn,

I am sorry, but I am not familiar with JSP-specific coding methods, nor do we really offer technical support for anything other than the XML-based IVR markups that we host. Assuming that your code below will populate a dynamic variable value to the form id attribute, then this should be what you will want to do.


~Matt
jefo12
6/23/2008 6:45 AM (EDT)

suppose i hav one form1 and in that i hav fied1,field2,field3...
and form2 in that i hav field4,field5,field6..



Is it possible to go to field 4 of form 2 directly from form 1



plz suggest me....
voxeojohnq
6/23/2008 9:33 AM (EDT)
Hey jefo,

Good news!  There is in fact a way to jump around to different fields in different forms within the same document. Although, it is not as simple as using a <goto> to jump to the beginning of a seconds form.  In this case, you would have to set up a "next field" type variable.  This would hold the name of the field in the next form that you would want to go to.  So what happens is that when you are ready to leave the first form, you would fill the "next field" variable.  Then, you jump to the next form.  Once there, you check the "next field" variable to see if it has a field name in it.  If it does, you do a <goto expritem="" /> to jump to the desired field.

In case that was a little cryptic, I wrote a sample vxml script to help you out.

<?xml version="1.0" encoding="UTF-8" ?>
<vxml version="2.1">
<!-- This is the next field varaible
  set this to whatever field you want to goto
  or leave it blank to start at the beginning of the form -->
<var name="next_field" />

<form id="form1">
  <field name="field1">
    <grammar type="text/gsl">[[ dtmf-1 ]]</grammar>
    <prompt>This is field 1</prompt>
   
    <filled>
      <prompt>filled</prompt>
     
      <!-- YAY we filled the grammar!!-->
      <!-- set the next field variable to the desired field -->
      <assign name="next_field" expr="'field3'" />
      <goto next="#form2" />
    </filled> 
  </field>
 
 
</form>

<form id="form2">
  <block>
    <prompt><value expr="next_field" /></prompt>
    <!-- check to see if next field has a field name in it -->   
    <if cond="next_field != ''">
      <!-- it is filled! goto the next field!! -->
      <goto expritem="next_field" />
    </if>
  </block>

  <field name="field2">
    <grammar type="text/gsl">[[ dtmf-1 ]]</grammar>
    <prompt>This is field 2</prompt>
  </field>
 
  <field name="field3">
    <grammar type="text/gsl">[[ dtmf-1 ]]</grammar>
    <prompt>This is field 3</prompt>
    <exit />
  </field>
</form>
</vxml>


I hope this helps you out!  If you have any further questions, please don't hesitate to ask.

Regards,

John Quinn
Voxeo Support

login



© 2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site