How To: Create a select box with dynamically-generated options |
Article Type | How To |
Title | Create a select box with dynamically-generated options |
| <i>I have a table, call it "Fruit", which contains rows "Orange", "Pear", and "Apple".<br>
<br>
I'd like to generate a select box which would allow me to select one of the fruit. When I hit "Submit" I would then be taken to the details page for that specific fruit. The select box would be populated with "Orange", "Pear" and "Apple", just as a select box belonging to a lookup field located in a different table pointing at the Fruit table would.<br>
<br>
Is there a way to do this without creating a new table that contains a lookup field into the Fruit table?</i><br>
<br>
Create a <a href="/default.view?Topic=ws00008">custom view</a>.
<br>
<span class="smallCode"><pre>
<form method="get" action="/fruitlist.view">
<select name="rowid">
<option value="0" />
<ws:dataregion layout="rawhtml" defaultmode="details"><ws:datasource src="fruit" />
<ws:field name="RowId" displaymodes="never" />
<ws:field name="fruitName" displaymodes="never" />
<option value="#record.rowid#">#record.fruitName#</option>
</ws:dataregion>
</select>
<ws:action />
</form>
</pre></span>
<br>
Note how I used our #substitution# syntax to populate the value and display text of the options. Also note how I set the layout of my dataregion to "rawhtml". This prevents the dataregion from trying to format my data for me.<br> |
Last Reviewed | February 20, 2015 14:08:44 |
|