Remove spaces from user search criteria

M

Max123

How can I tell FrontPage to trim leading and trailing spaces from search
criteria in database results?
Here's the problem I'm encountering: I have a single field search form in
which users enter a name such as "Smith" (without quotes). But sometimes
they enter "Smith " (without quotes but including a space) because they've
copied the name from elsewhere.
With the trailing space, the search results in no records. I'd like to trim
the spaces at the time the search criteria is processed. Ideally, this would
be done in the database results instead of the form because I have many forms
pointing to a single results page.
Thank you.
 
S

Stefan B Rusynko

Depending on how you are passing the "search" variable wrap it in a Trim

From a parameter use Trim(Request.QueryString("search"))
From a form field use Trim(Request.Form("search"))




| How can I tell FrontPage to trim leading and trailing spaces from search
| criteria in database results?
| Here's the problem I'm encountering: I have a single field search form in
| which users enter a name such as "Smith" (without quotes). But sometimes
| they enter "Smith " (without quotes but including a space) because they've
| copied the name from elsewhere.
| With the trailing space, the search results in no records. I'd like to trim
| the spaces at the time the search criteria is processed. Ideally, this would
| be done in the database results instead of the form because I have many forms
| pointing to a single results page.
| Thank you.
 
M

Max123

Thanks for replying Stefan.
I am not sure where to add the trim() function. The FP wizard created the
code below for the database results area. You can see that I added the
trim() function in the <!--webbot line. If I add it anywhere else, when I
save the page, FP overwrites the changes.
I'm wondering if it is actually possible to modify database results...
Thanks for any other thoughts you may have, Max

<!--webbot bot="DatabaseRegionStart"
s-columnnames="Display_Order,Photo,Emp_ID,Full_Name_KA,Last_Name_KA,First_Name_KA,Legal_Name,Email_HTML,On_Leave,Employee_Type,Display_Status,Hire_Date,Title,Location_1,Location_HTML,Contact,Manager,Organization,Cost_Center,Record_Source,NT_Name,Position_ID,Basic_Search,Last_Name_Search,First_Name_Search,Full_Name_Search,Full_Name_Search_Mgr,Emp_ID_Search"
s-columntypes="202,202,5,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202"
s-dataconnection="HRWebData" b-tableformat="TRUE" b-menuformat="FALSE"
s-menuchoice="Display_Order" s-menuvalue="Display_Order" b-tableborder="TRUE"
b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE"
b-listseparator="TRUE" i-listformat="0" b-makeform="TRUE"
s-recordsource="HRWeb_EmployeeSearch"
s-displaycolumns="Display_Order,Photo,Emp_ID,Full_Name_KA,Full_Name_Search,Last_Name_KA,First_Name_KA,Legal_Name,Email_HTML,On_Leave,Employee_Type,Display_Status,Hire_Date,Title,Location_1,Contact,Manager,Organization,Cost_Center,Record_Source,NT_Name,Position_ID,Full_Name_Search_Mgr,Last_Name_Search,First_Name_Search,Emp_ID_Search,Basic_Search,Location_HTML"
s-criteria="[Basic_Search] CNT trim({Basic_Search}) + [Display_Status] EQ
[Active] +" s-order="[Display_Order] +" s-sql="SELECT * FROM
HRWeb_EmployeeSearch WHERE (Basic_Search LIKE '%::Basic_Search::%' AND
Display_Status = 'Active') ORDER BY Display_Order ASC" b-procedure="FALSE"
clientside suggestedext="asp" s-defaultfields="Basic_Search=Enter a Value"
s-norecordsfound="Sorry, no matches found." i-maxrecords="0" i-groupsize="20"
botid="2" u-dblib="../../_fpclass/fpdblib.inc"
u-dbrgn1="../../_fpclass/fpdbrgn1.inc" u-dbrgn2="../../_fpclass/fpdbrgn2.inc"
tag="TBODY" preview="<tr><td colspan=64 bgcolor="#FFFF00" width="100%"><font
color="#000000">This is the start of a Database Results region. The page must
be fetched from a web server with a web browser to display correctly; the
current web is stored on your local disk or network.</font></td></tr>"
startspan b-WasTableFormat="TRUE" b-ReplaceDatabaseRegion="FALSE"
b-UseDotNET="FALSE" CurrentExt sa-InputTypes="202" b-DataGridFormat="FALSE"
b-DGridAlternate="TRUE" sa-CritTypes="202" --><!--#include
file="../../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database
Results component on this page is unable to display database content. The
page must have a filename ending in '.asp', and the web must be hosted on a
server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM HRWeb_EmployeeSearch WHERE (Basic_Search LIKE
'%::Basic_Search::%' AND Display_Status = 'Active') ORDER BY Display_Order
ASC"
fp_sDefault="Basic_Search=Enter a Value"
fp_sNoRecords="<tr><td colspan=28 align=""LEFT"" width=""100%"">Sorry, no
matches found.</td></tr>"
fp_sDataConn="HRWebData"
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=20
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Display_Order"
fp_sMenuValue="Display_Order"
fp_sColTypes="&Display_Order=202&Photo=202&Emp_ID=5&Full_Name_KA=202&Last_Name_KA=202&First_Name_KA=202&Legal_Name=202&Email_HTML=202&On_Leave=202&Employee_Type=202&Display_Status=202&Hire_Date=202&Title=202&Location_1=202&Location_HTML=202&Contact=202&Manager=202&Organization=202&Cost_Center=202&Record_Source=202&NT_Name=202&Position_ID=202&Basic_Search=202&Last_Name_Search=202&First_Name_Search=202&Full_Name_Search=202&Full_Name_Search_Mgr=202&Emp_ID_Search=202&"
fp_iDisplayCols=28
fp_fCustomQuery=False
BOTID=2
fp_iRegion=BOTID
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top