Hi,
I have limited experience with templating and SQL so looking for some guidance.
I'm attempting to populate cascading select lists using values from an MS SQL database.
I'm querying two tables. The first table lists the software platform name, i.e Windows Server and the second table lists the version, i.e. 2008 R2.
Using my query and the code below, I've been able to successfully populate the "Platform" and "Version" select lists, but my Platform list has repeating values. How do I specify a one to many relationship in my template so only one instance of the platform is listed?
Example:
image2016-8-31 10:39:41.png
Also, there's no dependency between the two lists. (no cascading functionality) I'd like to be able to select a platform and only have the versions associated with that platform listed in the "Version" select list.
<form id="my-pocketquery-form" class="aui">
<div class="field-group">
<label for="select-platform">Choose Platform:</label>
<select class="select" id="select-platform" name="select-platform">
#foreach ($platform in $result)
<option value="$platform.platform" #if($platform.platform == '.NET Framework')selected="selected"#end>$platform.platform</option>
#end
</select> <br>
<label for="select-version">Choose Version:</label>
<select class="select" id="select-version" name="select-version">
#foreach ($version in $result)
<option value="$version.version" #if($version.version == '1')selected="selected"#end>$version.version</option>
#end
</select>
</div>
</form>
$PocketQuery.renderPocketQueryMacro("Result_Query", {
'page': $page,
'parameters': {'Platform':'.NET Framework'},
'parameters': {'Version':'1'},
'dynamicload': true
})
<script>
jQuery('#my-pocketquery-form select').change(function() {
var container = jQuery('.pocketquery-dynamic-load[data-query="Result_Query"]');
var dataIndex = container.data('index');
var data = PocketQuery.getDynamicLoadData(dataIndex);
data.queryParameters = { VersionPlatform: jQuery('#select-platform').val() };
data.queryParameters = { VersionPlatform: jQuery('#select-version').val() };
PocketQuery.load({
container: container,
data: data
});
});
</script>
$PocketQuery.template("default")
Thanks,
Dan