# \<submit>

## \<submit> <a href="#submit" id="submit"></a>

The `<submit>` element is used to submit information to the origin web server and then transition to the document sent back in the response. Unlike `<goto>`, it lets you submit a list of variables to the document server via an HTTP GET or POST request.

### Attributes

<table><thead><tr><th width="170.33333333333331">Name</th><th width="157">Data type<select><option value="00d68ceb59ac455bb72dc2ff3ce6af62" label="String" color="blue"></option><option value="59e2cac383d24fcbb996acf51ef5041d" label="Integer" color="blue"></option><option value="c8a6aaf6bedd4c5583687825e5d19d57" label="Boolean" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>fetchhint</td><td></td><td>This attribute is not supported.</td></tr><tr><td>fetchtimeout</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>(defaults to “fetchtimeout” global property value) The timeout for fetches. Must be specified with the appropriate time units (e.g., “120s” for 120 seconds).</td></tr><tr><td>maxage</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>(defaults to “documentmaxage” global property value) Tells the platform the maximum acceptable age, in seconds, of cached documents.</td></tr><tr><td>maxstale</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>(defaults to “documentmaxstale” global property value) Tells the platform the maximum acceptable staleness, in seconds, of expired cached documents.</td></tr><tr><td>next</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>The URI reference.</td></tr><tr><td>expr</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>Like <code>next</code>, except that the URI reference is dynamically determined by evaluating the given ECMAScript expression.</td></tr><tr><td>fetchaudio</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>(defaults to “fetchaudio” global property value) The URI of the audio clip to play while the fetch is being done.</td></tr><tr><td>method</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>(defaults to “get”) The request method: "get", "post", or "raw".</td></tr><tr><td>enctype</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td><p>(defaults to “application/x-www-form-urlencoded”) This attribute specifies the HTTP POST encoding format.</p><p></p><p>Accepted values include the following:</p><ul><li>“multipart/form-data”: used when binary data is being submitted.</li><li>“application/xml”: used when fetching raw XML.</li><li>“application/json”: used when fetching raw JSON.</li></ul></td></tr><tr><td>rawexpr</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td>The raw XML or JSON string to submit to the URI. You can only use this attribute when using the “raw” method and either the “application/xml” or “application/json” enctype.</td></tr><tr><td>namelist</td><td><span data-option="00d68ceb59ac455bb72dc2ff3ce6af62">String</span></td><td><p>The list of variables to submit. The default is to submit no variables.</p><p></p><p>If a namelist is supplied, it may contain individual variable references that are submitted with the same qualification used in the namelist. Declared VoiceXML and ECMAScript variables can be referenced.</p></td></tr></tbody></table>

### Notes

Exactly one of “next” and “expr” must be specified.

When setting the “method” attribute to “post”, the platform does a normal POST with the variables passed in the namelist encoded as “application/x-www-form-urlencoded” or “multipart/form-data”. After encoding the namelist, the platform passes the data and tells the server that the data is encoded with whatever format it used to encode.&#x20;

However, when setting the “method” attribute to “raw”, the “raw” type is still a POST request, but does two things to change the default behavior, allowing control over both the data and the encoding type reported to the server:&#x20;

1. Rather than encoding the namelist to create the “data”, the platform instead executes the rawexpr javascript expression and uses the result for the data.&#x20;
2. It passes the encoding that was provided in the “enctype” attribute as the encoding to the web server.

### Example

{% tabs %}
{% tab title="start.php" %}

```php
<?php
  header("Content-type: text/xml");
  echo "<?xml version=\"1.0\"?>\n";
?>

<vxml version="2.0">
  <var name="license_number"/>
  <var name="request_type"/>
  <form>
    <field name="license" type="digits">
      <prompt>
        Please enter your driver's license number.
      </prompt>
      <filled>
        <assign name="license_number" expr="license"/>
      </filled>
    </field>
    <field name="request">
      <grammar type="application/srgs+xml" mode="dtmf" root="choice" maxdigits="1">
        <rule id="choice">
          <one-of>
            <item>1</item>
            <item>2</item>
          </one-of>
        </rule>
      </grammar>
      <prompt>
        To renew your license, press 1. To request a new license plate, press 2.
      </prompt>
      <filled>
        <assign name="request_type" expr="request"/>
        <submit next="process_request.php" method="post" namelist="
        license_number request_type" fetchtimeout="60s"/>
      </filled>
    </field>
  </form>
</vxml>
```

{% endtab %}

{% tab title="process\_request.php" %}

```php
<?php
  header("Content-type: text/xml");
  echo("<?xml version=\"1.0\"?>\n");
  // get the variables posted to this script
  $name = $_POST['license_number'];
  $license = $_POST['request_type'];
  // here we could process the data by entering the information into a database or calling a webservice
?>

<vxml version="2.0">
  <form>
    <block>
      <prompt>
        Thank you. We will process your request and get back to you shortly. Goodbye.
      </prompt>
      <exit/>
    </block>
  </form>
</vxml>
```

{% endtab %}
{% endtabs %}

The output of the above script would be:

> Computer: Please enter your driver's license number.\
> Human: \<user enters: 1 2 3 4 5>\
> Computer: To renew your license, press 1. To request a new license plate, press 2.\
> Human: \<user enters: 2>\
> Computer: Thank you. We will process your request and get back to you shortly. Goodbye.

### Child Tags

None

### Parent Tags

[\<block>](https://docs.plumvoice.com/dev/voicexml/tags/block-tag), [\<catch>](https://docs.plumvoice.com/dev/voicexml/tags/catch-tag), [\<error>](https://docs.plumvoice.com/dev/voicexml/tags/error-tag), [\<filled>](https://docs.plumvoice.com/dev/voicexml/tags/filled-tag), [\<foreach>](https://docs.plumvoice.com/dev/voicexml/tags/foreach-tag), [\<help>](https://docs.plumvoice.com/dev/voicexml/tags/help-tag), [\<if>](https://docs.plumvoice.com/dev/voicexml/tags/if-tag), [\<noinput>](https://docs.plumvoice.com/dev/voicexml/tags/noinput-tag), [\<nomatch>](https://docs.plumvoice.com/dev/voicexml/tags/nomatch-tag)
