# \<assign>

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

The `<assign>` element assigns a value to a predefined variable.

### Attributes

<table><thead><tr><th width="222">Name</th><th width="143.33333333333331">Data type<select><option value="07bc2ffa63524ba9a2909e475e464b22" label="String" color="blue"></option><option value="120b6a4017084eadb25acf7eae3c4a2e" label="Integer" color="blue"></option><option value="99202b51e1d14812838fd9c1e783f75e" label="Boolean" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>name</td><td><span data-option="07bc2ffa63524ba9a2909e475e464b22">String</span></td><td>The name of the variable being assigned to.</td></tr><tr><td>expr</td><td><span data-option="07bc2ffa63524ba9a2909e475e464b22">String</span></td><td>An ECMAscript expression to be evaluated, the results of which are assigned to the named variable.</td></tr></tbody></table>

## Notes

The variable specified by the “name” attribute in the `<assign>` tag should be declared in a `<var>` tag first.

### Example

```markup
<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <!-- test_var is declared here -->
    <var name="test_var"/>
    <block>
      <!-- test_var must be declared before assigning it a value -->
      <assign name="test_var" expr="1234"/>
    </block>
    <block>
      <prompt>
        The test variable is set to <value expr="test_var"/>.
      </prompt>
    </block>
  </form>
</vxml>
```

The output of the above script would be:

> Computer: The test variable is set to twelve hundred thirty-four.

### 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)
