Hi Scott,

The answer is fairly simple - which is a nice change.


My example below is update some fields based on what is entered into another 
(text) filed.

It does use the jQuery core so make sure that you have that loaded and ensure 
that it is working (I.e. the "$" shortcut is working)
Also, that initial text field uses the jQuery autocomplete plugin so that you 
don't have to type in exact match in the text box.

I realise that your post speaks about using select boxes - but the premise is 
the same;
Simply use the onChange event of the select box to fire the appropriate JS..

>From memory I constructed all my code using the examples from the jQuery 
>website (and the demos from the plugins that were used)
Hopefully the code below will serve as  an example you can build upon.


I have a JS file that is included within the file that does the displaying;

<!--- myJSFile.js --->
//Create the AJAX request object
var ajaxObj=createRequest();

//Set the separator for fields/columns in the eturned data
var mySeperator = "|";

$(document).ready(function(){
        //set the page to call when auto completing the part number field
        var partNumber_destURL = "autocomplete_partNumber.cfm";


//run the Query autocomplete plugin for part numbers - align form names to 
column names
$("#partNumber").autocomplete(partNumber_destURL,{minChars:2, max:40000})
        .result(function (evt, data, formatted) 
                {
                        $("#partNumber").val(data[1]);
                        $("#productDescription").val(data[2]);
                        $("#unitCost").val(data[3]);
                });

});
<!--- end myJSFile.cfm -->



And then have your appropriate code in the file mentioned in your javascript, 
which in this case is;
autocomplete_partNumber.cfm



The contents of that file are pretty much, run a query return the results;

<!---
<fusedoc fuse="autocomplete_partNumber.cfm" language="ColdFusion" 
specification="2.0">
        <responsibilities>
                I query the database for inventory information.
                The WHERE clause of the query is passed into me via the 'q' url 
variable.
                I provide a PIPE delimited recordset back to the form I was 
called from
        </responsibilities>
        <io>
                <in>
                        <string name="q" scope="url" />
                </in>
                <out>
                        <recordset name="qry_partNumbersSELECT" 
scope="variables">
                                <string name="pn" />
                                <string name="desc" />
                                <number name="unitcost" />
                        </recordset>
                </out>
        </io>
</fusedoc>
--->

<!--- provide no output to the screen --->
<cfsilent>
        <!--- suppress debug information --->
        <cfsetting showDebugOutput = "no" >

        <!-- get the matching data from the database --->
        <cfquery name="qry_partNumbersSELECT" datasource="WinMagi">
                SELECT
                        invt.pn,
                        invt.desc,
                        
invt.fsmat+invt.fspsvc+invt.fslab+invt.fsfod+invt.fsvod+invt.fsscrp as unitcost
                FROM
                        inv invt
                WHERE
                        upper(invt.pn) like upper('#url.q#%')
                order by
                        invt.pn asc
        </cfquery>

        <!-- create an EOL --->
        <cfset newline = chr(13) & chr(10)>
</cfsilent>

<!--- loop through the recordset and create a PIPE delimited recordset --->
<cfoutput>
        <cfloop query="qry_partNumbersSELECT">
                #pn# - (#desc#)|#pn#|#desc#|#unitcost##newline#
        </cfloop>
</cfoutput>

Let me know if you need anything more and I'll see if I can squeeze in writing 
a select box demo for you overnight.



As always, please contact me if I can be of any futher assistance.

Gavin "Beau" Baumanis
Senior Application Developer
PalCare Pty. Ltd.

P: +61 -3 9380 3513
M: +61 -438 545 586
E: b...@palcare.com.au
W: http://palcare.com.au



On 12/10/2010, at 8:49 AM, Scott Thornton wrote:

> Hello,
>  
> I am looking for a solution that will allow Ajax-y style updates of a 
> database when a user changes a value in one of many select boxes in a form.
>  
> EG: Say there are 20 select boxes in a form with Yes or No Options. Changing 
> the value will perform a database update without the usual form submit\page 
> refresh rigmarole.
>  
> I have been looking through the coldfusionjedi website, but no example stands 
> out.
>  
> Can anyone point me in the correct direction?
>  
> I am guessing that the solution uses jquery… just have never done much stuff 
> with it before.
>  
> The solution should work in CF MX 6.1
>  
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "cfaussie" group.
> To post to this group, send email to cfaus...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cfaussie+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cfaussie?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaus...@googlegroups.com.
To unsubscribe from this group, send email to 
cfaussie+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en.

Reply via email to