Use variables and pass to AutoComplete function

Dec 13, 2012 at 11:13 PM
Edited Dec 13, 2012 at 11:16 PM

I have a need to insert variables into the call to SPAutoComplete dynamically, but have been unable to figure out how to pass variables. If I have something like this (it works great)

 

$().SPServices.SPAutocomplete({
 sourceList: "NDA", 
 sourceColumn: "Title", 
 columnName: "NDAField", 
 CAMLQuery: "2012",
...
}

 

I would like to do something like this, but it takes the value literally.

 

var A= "NDA";
var B = "2012";
var C = "[first part of CAMLQuery]"+ B +"[last part of CAMLQuery]";
$().SPServices.SPAutocomplete({
 sourceList: A, 
 sourceColumn: "Title", 
 columnName: "NDAField", 
 CAMLQuery: C,
...
}

 

I need suggestions on how to accomplish the desired task.

Coordinator
Dec 14, 2012 at 3:17 AM

What you're doing with A, B, and C ought to work. If you look at SPServices, you'll see quite a few places where I build the CAMLQuery and other values in variables. When you say it doesn't work, what is happening? Have you stepped through it?

M.