Link to home
Start Free TrialLog in
Avatar of AboutLotus
AboutLotus

asked on

search not working when apostrophe is used

I search the info based on name. I get the name from the user thru a form which has the following code
I have a field "emp_search" to get the value.

<script language="JavaScript">
function empsearch(form){
var query = form.emp_search.value+"*";
var href = form.dbpath.value + "/Searchemployee?SearchView&query=[LastName]="+query+"&SearchOrder=4";
location.href=(href);
}
</script>

and the Searchemployee view is like this
lastname                value
abella            <script> var color=((2%2)==1)? 'eeeeee':"#ffffff";  document.write       ('<table width=100% border=0 cellpadding=2 cellspacing=0 bordercolor=dddddd align=center><tr bgcolor='+color+'><td class="results" width=40%>Abella, Gabriel</td><td class="results">713-767-4712<td align="right">
<a href="/dynintranet/phonelist.nsf/Searchemployee/5D4E69C0237C6A0A86256DF200740D0D" class="results2">more...</a></td></tr></table>'); </script></td></tr></table></TD></TR>


this view has details for all the last name.

The problem is when I give the last name with apostrophe it is not searching. eg if I give O'Meara it is not searching.

How can I avoid this?

Please help me.


Thanks in advance

Avatar of HemanthaKumar
HemanthaKumar

Include double qoutes around query

eg:

var href = form.dbpath.value + "/Searchemployee?SearchView&query=[LastName]=\""+query+"\"&SearchOrder=4";


~Hemanth
Avatar of AboutLotus

ASKER

Hey I tried that too but its not working.
You must use the translated codes in your script, eg. %20 for space.

I can't tell you what ' is from the top of my head, but I'm sure you'll be able to find it somewhere....

cheers,

Tom
Ok , try %27 .

var href = form.dbpath.value + "/Searchemployee?SearchView&query=[LastName]=\"O%27Meara\"&SearchOrder=4";

cheers,

Tom
I tried %27 and it is not working still.

Please help me with this.
try this:

var href = form.dbpath.value + "/Searchemployee?SearchView&query=[LastName]="+unescape(query)+"&SearchOrder=4";

Partha
This is also not working
SOLUTION
Avatar of HemanthaKumar
HemanthaKumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A workaround: change all of your docs so that a new field for searching is added

  FIELD LastNameEncoded := @URLEncode( "Domino"; LastName );

Then change the query so that it looks inside LastNameEncoded

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey guys thanks a lot for all who have taken pain in answering my ques.

Thanks
NOTE

the problem described in this question is NOT an issue for my notes system (using Notes 6.5.1)... ie I can search for an apos with total control without any problem, and I tested it both remotely through the web browser and locally in the notes client!!

For example,
the document with title like                           is found when searching         hits
-------------------------------------------------------------------------------------------------
11'09''01 - September 11 (2002)                   [title]=''                                1
Rosemary's Baby (1968)                               [title]='                                 60
Buffalo '66 (1998)                                        [title]='66                              2
Matrimonio all'italiana (1964)                        [title]=all'italiana                    1


---
Just for posterity,

my formula in comment #12228515 is wrong. This one works instead:
  FIELD LastNameEncoded := @ReplaceSubstring( LastName; {'}; "_" );
and when searching for something with an apos, do the same substitution and look inside the LastNameEncoded field.
---