XModPro

Use of Case for dependent dropdown in template

Harry Allan Harry Allan asked May 20, 2015
Active May 20 · Viewed 2028 times
<p>Hi I'm a bit confused on using the case statement and if I should even be using it for this purpose?</p><p>I have 2 dropdowns in different Template sections being pulled from a database. I want to have the second dropdown only display the cities relating to the countryID in the first dropdown, the country values are 6, 7 and 8. The code below works for only showing item 6 on the second dropdown but when I change the country dropdown it does nothing to the city dropdown (yes I know I'm only creating 1 case but adding others seems to do nothing):</p><p>&lt;xmod:Template UsePaging="False" Ajax="False"&gt;</p><p> &lt;ListDataSource CommandText="SELECT id, countryName FROM country ORDER BY countryName ASC" ConnectionString='[[ConnectionString:Excursions]]'/&gt;</p><p> &lt;HeaderTemplate&gt;</p><p> &lt;label&gt;Country: &lt;/label&gt;</p><p> &lt;select id="ddl-country"&gt;</p><p> &lt;option value=""&gt;&lt;/option&gt;</p><p> &lt;/HeaderTemplate&gt;</p><p> &lt;ItemTemplate&gt;</p><p> &lt;option value="[[id]]"&gt;[[countryName]] | id = [[id]]&lt;/option&gt;</p><p> &lt;/ItemTemplate&gt;</p><p> &lt;FooterTemplate&gt;</p><p> &lt;/select&gt;</p><p> &lt;/FooterTemplate&gt;</p><p>&lt;/xmod:Template&gt;</p><p>&lt;xmod:Template id="city" UsePaging="False" Ajax="False"&gt;</p><p> &lt;ListDataSource CommandText="SELECT countryID, cityName FROM city" ConnectionString='[[ConnectionString:Excursions]]'&gt;</p><p> &lt;/ListDataSource&gt;</p><p> &lt;HeaderTemplate&gt;</p><p> &lt;label&gt;City: &lt;/label&gt; </p><p> &lt;select id="ddl-city"&gt;</p><p> &lt;/HeaderTemplate&gt;</p><p> &lt;ItemTemplate&gt;</p><p> &lt;xmod:Select&gt;</p><p> &lt;case comparetype="numeric" operator="=" value='[[countryID]]' expression="6" ignorecase="true"&gt;</p><p> &lt;option value="[[countryID]]"&gt;[[cityName]] | id = [[countryID]]&lt;/option&gt;</p><p> &lt;/case&gt;</p><p> &lt;else&gt;</p><p> &lt;p&gt;blah&lt;/p&gt;</p><p> &lt;/else&gt;</p><p> &lt;/xmod:Select&gt;</p><p> &lt;/ItemTemplate&gt;</p><p> &lt;FooterTemplate&gt;</p><p> &lt;/select&gt;</p><p>&lt;/FooterTemplate&gt;</p><p> &lt;/xmod:Template&gt;</p><p>Any help is appreciated.</p>

4 Answers

Loading answers...