Select to view content in your preferred language

query.where syntax issue

1203
12
Jump to solution
04-09-2014 06:53 AM
williamcarr
Frequent Contributor
2 part question:

The first part is getting the value of
  <select class="field" name="field" id="selectfield">        <option value="FIRSTNAME">First Name</option>   <option value="LAST_NAME">Last Name</option>   <option value="Service_ID">Service ID</option>   <option value="TOWNSHIP">Township</option> </select>


to be a variable in a query.where

var sel = dom.byId("input1").value; query.where = "  (select option variable) LIKE'" + sel +"'"; 


Essentially we need the user to select the query field in from the drop down menu. I'm hoping this is possible and I'm just running into syntax issues.

The second part is making the query accept partial or misspelled text inputs. I'm new to JS and this is really racking my brain. Any help is appreciated.
0 Kudos
12 Replies
TimCollyer
Regular Contributor
Can you log your query.where to the console?

I'm not sure if it is your only problem, but at a first glance it looks like you're probably missing a space before the "LIKE" in this line:

query.where = optionValue + "LIKE '%" + sel +"%'";
0 Kudos
williamcarr
Frequent Contributor
Paydirt!!

The log showed "FIRSTNAMELIKE '%ted%'" so I inserted an extra space in the " LIKE '%" to make it "FIRSTNAME LIKE '%ted%'"...

Thanks, you guys have restored my faith in humanity.
0 Kudos
JeffPace
MVP Alum
glad to help, please mark the thread as answered by checking the checkmark in the appropriate post, and also hit the up arrow on any post you deemed helpful so that others can see the answer as well
0 Kudos