Here is my query where clause:
query1.where = "(name) ='" + dom.byId("SUB").value + "'";
When I run a query, 90% query will return results except if the data has " ' ". For example, if my data has a name called "BRIAN'S ESTATES" then query won't return any results even though you enter the exact same name. Got ideas to change the where clause?
Thanks.
Solved! Go to Solution.
Jeff,
This is because you will have to escape your single quote in the entered value for the expression to work.
So you have to check if the dom.byId("SUB").value has a single quote and if so then use the replace method to escape it.
var usrVal = dom.byId("SUB").value.toString();
if(usrVal.indexOf("'") > -1){
usrVal = usrVal.replace(/'/g,"''");
}
Jeff,
This is because you will have to escape your single quote in the entered value for the expression to work.
So you have to check if the dom.byId("SUB").value has a single quote and if so then use the replace method to escape it.
var usrVal = dom.byId("SUB").value.toString();
if(usrVal.indexOf("'") > -1){
usrVal = usrVal.replace(/'/g,"''");
}