{"id":385,"date":"2010-09-22T08:55:45","date_gmt":"2010-09-22T12:55:45","guid":{"rendered":"http:\/\/erics-test-lab.com\/?p=385"},"modified":"2010-09-22T08:55:45","modified_gmt":"2010-09-22T12:55:45","slug":"cfselect-multiple-and-listqualify","status":"publish","type":"post","link":"https:\/\/www.esearing.com\/v2010\/2010\/09\/cfselect-multiple-and-listqualify\/","title":{"rendered":"CFSelect Multiple and ListQualify"},"content":{"rendered":"<p>If you need a multiple selection list and need to display its values dynamically from a query you can do this in one line of code within your form.<\/p>\n<p><code>&lt;cfquery name=\"getstatus\" datasource=\"myDSN\"&gt;<br \/>\nselect All as status from orderstable<br \/>\nUNION ALL<br \/>\nselect distinct status from orderstable<br \/>\n&lt;\/cfquery&gt;<br \/>\n&nbsp;<br \/>\n&lt;cfform ...&gt;<br \/>\n&lt;cfselect name=\"status\" query=\"getstatus\" value=\"status\"  multiple=\"yes\" \/&gt;<br \/>\n...<br \/>\n&lt;\/cfform&gt;<\/code><br \/>\nThe result is a form with a multiple selection of order statuses .<\/p>\n<p>To use the selected statuses after form submission you write the query using ListQualify, that returns a copy of the list, with qualifier (singlequotes) before and after the specified element(s).<br \/>\nI also set a default cfparam for status=&#8221;All&#8221;<br \/>\n<code>&lt;cfparam name=\"Form.status\" default=\"All\"&gt;<br \/>\n&lt;cfquery name=\"getdata\" datasource=\"myDSN\"&gt;<br \/>\nselect * from orderstable<br \/>\n&lt;cfif #FORM.tkt_status# neq \"All\"&gt;where status in (#ListQualify(FORM.status,\"'\")#)&lt;\/cfif&gt;<br \/>\n&lt;\/cfquery&gt; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you need a multiple selection list and need to display its values dynamically from a query you can do this in one line of code within your form. &lt;cfquery name=&#8221;getstatus&#8221; datasource=&#8221;myDSN&#8221;&gt; select All as status from orderstable UNION ALL &hellip; <a href=\"https:\/\/www.esearing.com\/v2010\/2010\/09\/cfselect-multiple-and-listqualify\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,16,24,14],"tags":[],"class_list":["post-385","post","type-post","status-publish","format-standard","hentry","category-code","category-coldfusion","category-snippets-quick-code-tips-for-single-elements-attributes-or-details","category-sql"],"_links":{"self":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/comments?post=385"}],"version-history":[{"count":0,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/385\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/media?parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/categories?post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/tags?post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}