How do I add parameters to autocomplete call?

How do I add parameters to autocomplete call?

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) - 
  1. <HEAD>
  2. <!--- Used for Part Number Autocomplete ---->
  3. <!---- This also uses partEnqAutocompleteQuery.cfc to do the callback ---->
  4.   <link rel="stylesheet" href="../jQuery3.1.0/jquery-ui-1.12.0.custom/jquery-ui-theme-base.css">
  5.     <link rel = "stylesheet" href = "/agconetTplTest11/styles/DaveStyle.css">  
  6.    <script type="text/javascript" language="javascript" src="../jQuery3.1.0/jquery-3.1.0.min.js"></script> 
  7.    <script type="text/javascript" language="javascript" src="../jQuery3.1.0/jquery-ui-1.12.0.custom/jquery-ui.min.js"></script>
  8.     
  9.     <script>
  10.          $(function() {  
  11.             $( "#PARTPASS" ).autocomplete({minLength: 3, source: 'partEnqAutocompleteQuery.cfm'});  
  12.          });  
  13.     </script>  
  14. <!--- end of Autocomplete code ---->
  15. :
  16. </head>
  17. :
  18. <body>
  19. <form>
  20. :
  21. <td><div class="ui-widget"> 
  22.                 <INPUT type = "Text" name = "PARTPASS"  id = "PARTPASS" SIZE = "15" MAXLENGTH = "15" class = "partsAutoComplete" > 
  23.                 </div> 
  24.             </td>           
In partEnqAutoCompleteQuery.cfm

  1. <cfparam name = "url.term" default = "">
  2. <!--- Bring back a list of part numbers that start with the entered characters. --->
  3. <cfstoredproc procedure="SPGETPARTENQAUTO" datasource="#Application.MVXDS#" returncode="yes">
  4.     <cfprocparam cfsqltype="cf_sql_varchar" value=#Application.MVXDT#> <!--- M3 Library  --->
  5.     <cfprocparam cfsqltype="cf_sql_integer" value="501">                 <!--- Company Number --->
  6.     <cfprocparam cfsqltype="cf_sql_varchar" value="#url.term#">             <!--- Search String --->
  7. <cfprocresult name="parts">
  8. </cfstoredproc>

  9. <cfset session.partslist = ArrayNew(1)>  <!--- full list of parts --->
  10. <cfloop query = "parts">
  11. <cfset p = StructNew()>
  12.     <cfset p["label"] = "#parts.mmitno# - #parts.mmitds#">
  13.     <cfset p["value"] = parts.mmitno>
  14.     <cfset ArrayAppend(session.partslist,p)>
  15. </cfloop>  

  16. <cfset json = SerializeJSON(session.partslist)>
  17. <cfcontent reset="true" type="application/json"><cfoutput>#json#</cfoutput><cfabort>
I need to add two String parameters to the Stored Procedure. The values for these parameters would not be entered by the user, but would be variables determined by the coldfusion code.
  • 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.