Trying to perform a query task that searches two separate fields. The user text input can either be the Name field or a Docket field.
// Executes on each button click
function doQuery() {
// Set the search text to the value of the input box
document.getElementById("inputTxt").value
queryParams.where = "Name like '%" + document.getElementById("inputTxt").value + "%'";
layer.queryFeatures(queryParams).then(showResults);
}
Appreciate the help.
Solved! Go to Solution.
Ryan,
If you are searching the two fields for the same value from the user input then use code like this:
var userInput = document.getElementById("inputTxt").value;
queryParams.where = "Name like '%" + userInput + "%' OR Docket like '%" + userInput + "%'";
Ryan,
If you are searching the two fields for the same value from the user input then use code like this:
var userInput = document.getElementById("inputTxt").value;
queryParams.where = "Name like '%" + userInput + "%' OR Docket like '%" + userInput + "%'";
Sorry Robert, I should be more clear. The user will either search by one field or another. So it would be different values.
Example. The user could know the subdivision name or the docket number. Would like them to be able to search by either option.
Name = RNJ or Docket = 1-15-2018
So do you have two different user inputs? How do you determine which they are searching for?
Only one user text input. Im using this example http://jsbin.com/veyaqa/edit?html,output
As always. Thanks for your time Robert!
Ryan,
Then you will have to add a checkbox, dropdown or something that will distinguish which field they want to search one or you just use the code I posted in my first reply and let it search both fields for the entered value.
Im an idiot lol. It works perfectly. Thank you Sir!