Cascading dropdown in coldfusion


Include latest version of jQuery in your page with following javascript code:

    <script type="text/javascript">
        function fun_changeCustomer(customerId) {
            var url = '';
            url = "/cfc/customerBillingAddressGateway.cfc?";
            url = url + 'method=getAddressInfoByCustomerIdQuery&returnFormat=json&argumentCollection={"customerId": ' + customerId + '}';
            jQuery.getJSON(url, function (data) {
                $("#billingAddress").empty();
                $("#billingAddress").append("--Select--");
                $.each(data.DATA, function (index, optionData) {
                    if ('#form.billingAddress#' == optionData[0]) {
                        $("#billingAddress").append("" + optionData[1] + "");
                    }
                    else {
                        $("#billingAddress").append("" + optionData[1] + "");
                    };
                });
            });
        }
    </script>

Your cfc class (here: customerbillingAddressGateway.cfc) should have following method with remote access:
e.g.
cffunction name=”getAddressInfoByCustomerIdQuery” access=”remote” output=”false” returntype=”query”

It should contain a normal select query that returns the addressId and addressInfo.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s