XForms/Selecting Text
Appearance
< XForms
Motivation
[edit | edit source]You want to use a selection list to conditionally populate a text area.
<xf:model>
<xf:instance id="save-data">
<data xmlns="">
<message-type>test-message-1</message-type>
<current-message/>
</data>
</xf:instance>
<xf:instance id="code-table">
<data xmlns="">
<messages>
<message type="test-message-1">Message Type 1</message>
<message type="test-message-2">Message Type 2</message>
<message type="test-message-3">Message Type 3</message>
</messages>
</data>
</xf:instance>
<xf:bind nodeset="instance('save-data')/current-message"
calculate="instance('code-table')/messages/message[@type = instance('save-data')/message-type]"/>
<xf:submission id="post-test" method="post" action="echo-post.xq"
instance="save-data" replace="all"/>
</xf:model>
<body>
<p>Enter a message in the text area below and press the "Submit via HTTP POST" button.</p>
<div class="block-form">
{$style}
<xf:select1 ref="message-type" class="message">
<xf:label>Message Type:</xf:label>
<xf:item>
<xf:label>Test Message 1</xf:label>
<xf:value>test-message-1</xf:value>
</xf:item>
<xf:item>
<xf:label>Test Message 2</xf:label>
<xf:value>test-message-2</xf:value>
</xf:item>
<xf:item>
<xf:label>Test Message 3</xf:label>
<xf:value>test-message-3</xf:value>
</xf:item>
</xf:select1>
<xf:textarea ref="current-message">
<xf:label>Message:</xf:label>
</xf:textarea>
</div>
<xf:submit submission="post-test">
<xf:label>Submit via HTTP POST</xf:label>
</xf:submit>
</body>