How do I add parameters to autocomplete call?
in Using jQuery Plugins
•
5 years ago
I currently use Autocomplete with Coldfusion to run a DB2 Stored procedure. The user starts to enter a part number and autocomplete returns a list of matching part numbers. This works fine but I now need to add a couple of parameters to the query and have no idea how to change the autocomplete call to achieve this. I will admit that while I think jQuery is brilliant but I find it all very confusing and don't understand it enough to go beyond very basic usage.
Here's what I have now;
In the page where the user enters the part number (PARTENQ.cfm) -
- <HEAD>
- <!--- Used for Part Number Autocomplete ---->
- <!---- This also uses partEnqAutocompleteQuery.cfc to do the callback ---->
- <link rel="stylesheet" href="../jQuery3.1.0/jquery-ui-1.12.0.custom/jquery-ui-theme-base.css">
- <link rel = "stylesheet" href = "/agconetTplTest11/styles/DaveStyle.css">
- <script type="text/javascript" language="javascript" src="../jQuery3.1.0/jquery-3.1.0.min.js"></script>
- <script type="text/javascript" language="javascript" src="../jQuery3.1.0/jquery-ui-1.12.0.custom/jquery-ui.min.js"></script>
- <script>
- $(function() {
- $( "#PARTPASS" ).autocomplete({minLength: 3, source: 'partEnqAutocompleteQuery.cfm'});
- });
- </script>
- <!--- end of Autocomplete code ---->
- :
- </head>
- :
- <body>
- <form>
- :
- <td><div class="ui-widget">
- <INPUT type = "Text" name = "PARTPASS" id = "PARTPASS" SIZE = "15" MAXLENGTH = "15" class = "partsAutoComplete" >
- </div>
- </td>
- <cfparam name = "url.term" default = "">
- <!--- Bring back a list of part numbers that start with the entered characters. --->
- <cfstoredproc procedure="SPGETPARTENQAUTO" datasource="#Application.MVXDS#" returncode="yes">
- <cfprocparam cfsqltype="cf_sql_varchar" value=#Application.MVXDT#> <!--- M3 Library --->
- <cfprocparam cfsqltype="cf_sql_integer" value="501"> <!--- Company Number --->
- <cfprocparam cfsqltype="cf_sql_varchar" value="#url.term#"> <!--- Search String --->
- <cfprocresult name="parts">
- </cfstoredproc>
- <cfset session.partslist = ArrayNew(1)> <!--- full list of parts --->
- <cfloop query = "parts">
- <cfset p = StructNew()>
- <cfset p["label"] = "#parts.mmitno# - #parts.mmitds#">
- <cfset p["value"] = parts.mmitno>
- <cfset ArrayAppend(session.partslist,p)>
- </cfloop>
- <cfset json = SerializeJSON(session.partslist)>
- <cfcontent reset="true" type="application/json"><cfoutput>#json#</cfoutput><cfabort>
- What changes do I make to the autocomplete initialisation script?
- How do I access the parameters in partEnqAutoCompleteQuery.cfm?
Thanks for helping a jQuery tyro.
1