Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi everybody, here is the problem with my search box.(for example i have a product online name "lamp, hanging style, black" for me to search it i have to type in order to search it i can't type "black lamp" because its not gonna find it, but if i type "lamp, hang" then i can find it... any body know why? here is the code for that box
<%
':: Accware Online
':: ?Copyright 2000, ICODE Inc
':: Template: AMAZING
'*** Search.asp
%><script Language = "Javascript">
function submitMainsearch()
{/*
if (document.Mainsearch.edtSearchWords.value.indexOf(" ") == 0)
{
alert("Search string should not start with spaces.");
document.Mainsearch.edtSearchWords.focus();
return false;
}
if (document.Mainsearch.edtSearchWords.value.indexOf("\"") > -1 )
{
alert("Please enter a valid Search String.");
document.Mainsearch.edtSearchWords.focus();
return false;
}
if (document.Mainsearch.edtSearchWords.value == "")
{
alert("Please enter a Search String.");
document.Mainsearch.edtSearchWords.focus();
return false;
}document.Mainsearch.submit();
return true;
*/
var strValue;
strValue = new String(document.Mainsearch.edtSearchWords.value);
var strLen = strValue.length;if ((strValue == "")||(strValue==" "))
{
alert("Please enter a Search String.");
document.Mainsearch.edtSearchWords.focus();
return false;
}
if (document.Mainsearch.edtSearchWords.value.indexOf("\"") > -1 )
{
alert("Please do not enter \" inside Search String.");
document.Mainsearch.edtSearchWords.focus();
return false;
}
if(strValue.charAt(strLen-1)=="\\")
{
alert("Please do not end Search String with \\.");
document.Mainsearch.edtSearchWords.focus();
return false;
}//*** Checking for all spaces - Starts here
var AllSpaces = true;
for (i = 0; i < strValue.length; i++)
{
if (strValue.charAt(i) != " " )
{
AllSpaces = false;
break;
}
}
if (AllSpaces)
{
alert("Please enter a Search String.");
document.Mainsearch.edtSearchWords.focus();
return false;
}
//*** Checking for all spaces - Ends heredocument.Mainsearch.submit();
return true;
}
</script><%
Function search_FormatString(strName)
Dim m_Name, m_Tempm_Name = UCase(Mid(strName,1,1)) & LCase(Mid(strName,2))
m_Temp = 0While m_Temp <> -1
m_Temp = inStr(m_Temp+1,m_Name," ")
If m_Temp > 0 Then
m_Name = Mid(m_Name,1,m_Temp) & UCase(Mid(m_Name,m_Temp+1,1)) & Mid(m_Name,m_Temp+2)
Else
m_Temp = -1
End If
Wend
m_Name=Mid(m_Name,1,12) &"..."
search_FormatString = m_Name
End Function
'*** End Function
%>
<form name = "Mainsearch" method="post" action ="<%=g_NonSecurePath%>searchresult.asp?CartId=<%=cartid%>" onSubmit="return submitMainsearch('search','','');">
<input type="hidden" name="from">
<input type="hidden" name="FrmSearchWords">
<%Set objThirdParty = objSearch.GetThirdPartyInfo%>
thanx

Well, I'm not going to read through all of that code (please only post the relevant code), but the problem is pretty simple.
The EXACT string "black lamp" does not exist within "lamp, hanging style, black". But, "lamp, hang" does: "lamp, hanging style, black".
What you are after is called Full text searching where the search input is parsed into individual words and all the words are used for the search. This requires a database implementation. You'll have to find out the specifics for your environment.
Michael J

how do i implementate a better searching option like other website, as i know of i am the only website having that problem. it make search more complicate for others
thanx

it not that i don't want to post the relevant code..but i have limited knowlege on these codes...that's why i post what i konw that might be the one which cost the problem on here..sorry for the trouble
thanx

Well, the code you posted doesn't do any of the actual searching and reading code that is not related to the problem is a waste of time. If you are not sure what code to post, just state you can post code as requested.
As to your problem I can not offer any definitive solution. I typically use PHP & MySQL. It looks like you are using VBScript? and I have no clue to the database you are using. But, full text searching (which is what you are asking for and which I have already stated) is mostly dependant on the database. You should do a google search for "Full Text Searching [DB_Name]" Where DB_Name is the name of the type of database you are using.
Michael J

but i want them not to be in full text search, i want my customer search my whole website by entering either model number or part of the name(doesn't have to be in order)....not full text search
thanx

You are not understanding what Full Text Searching is.
Fine. On the page "searchresult.asp", or perhaps an included page, find the code that queries the database. Should be something along the lines of SELECT * FROM table name (just do a text search for the word select).
Post that code here.
Michael J

sorry for all the trouble but i really want it to work..here is the what i found in searchresult.asp i can not find what you are asking me to look for... and once again sorry for the trouble...thanx
<script language="JavaScript">/* ### This function will be called when the user clicks prev , next or searchagain.
### bm = bookmark
### nav = prev or next depends on the navigation clicked by the user.
### type = itemtype of the last product diplayed in the current list.
### all these three parameters will be null if user clicks search again.
*/
function submitSearch(bm,nav,type)
{
document.frmSearch.BookMark.value =bm;
document.frmSearch.prevnext.value = nav;
document.frmSearch.itype.value = type;
document.frmSearch.submit();
}
function validateqty(txtQty,code,which,code1)
{
var element;
var i,temp1,temp2;
element = "document.frmSearch" + ".qty" + txtQty + ".value";
temp1 = eval(element);
retval=IsNumeric(temp1);
if(retval == 1){
alert("Enter valid quantity");
eval("document.frmSearch" + ".qty" + txtQty + ".value=1");
eval("document.frmSearch" + ".qty" + txtQty + ".focus()");
return;
}
<%If Application("bAutoAdd") Then%>
//showAdd()
if(navigator.appName == "Microsoft Internet Explorer")
miniCart.document.location.replace("<%=g_NonSecurePath%>includes/minicart.asp?CartId=<%=CartId%>&qty=" + eval(element) + "&type=" + which + "&ic=" + code1 + "&tpc=<%=tpdata%>");
else
document.miniCart.document.first.src="<%=g_NonSecurePath%>includes/minicart.asp?CartId=<%=CartId%>&qty=" + eval(element) + "&type=" + which + "&ic=" + code1 + "&tpc=<%=tpdata%>";
return;
<%End if%>
document.frmAdd.qty.value = eval(element);
document.frmAdd.ic.value = code;
if(which=="K")
document.frmAdd.type.value = "kit";
document.frmAdd.submit();
}// This is the function to show added msg in IE (only for Auto Addition)
function showAdd()
{
if(showadd.style.visibility != "visible")
{
showadd.style.visibility = "visible";
showadd.style.top = bbody.scrollTop + 100;
setTimeout("showAdd()",1000);
}
else
showadd.style.visibility = "hidden";
}function validatewishqty(txtQty,code,which)
{
var element;
var i,temp1,temp2;
element = "document.frmSearch" + ".qty" + txtQty + ".value";
temp1 = eval(element);
retval=IsNumeric(temp1);
if(retval == 1){
alert("Enter valid quantity");
eval("document.frmSearch" + ".qty" + txtQty + ".value=1");
eval("document.frmSearch" + ".qty" + txtQty + ".focus()");
return;
}
document.frmWish.Wqty.value = eval(element);
document.frmWish.Wic.value = code;
document.frmWish.submit();
}
/*#### This uses regular expression for valid the entered parameter a valid numeric.*/
function IsNumeric(value)
{
var validate=/(^\d+$)/
if ((validate.test(value)) && (value > 0))
return 0;
else
return 1;
}
</script>
</body>
</html>

<select name="shop" size="1">
<option value="">Main Catalog</option>
<% If objThirdParty.Count > 0 Then%>
<%For m_Index = 1 to objThirdParty.Count%>
<option <%If (Trim(Request.Form("shop")) = objThirdParty.item(m_Index).code) Or (tpdata = objThirdParty.item(m_Index).code) Then%>Selected<%End If%> value="<%=objThirdParty.item(m_Index).code%>"><%=search_FormatString(objThirdParty.item(m_Index).name)%></option>
<%Next%>
<%end if%>
</select>
thanx

Sorry, but I can't see anything in the code that you've posted that actually does the searching. It looks to all be validation functions.
Michael J

Michael, do you know where can i learn how to write database for the website? thanx for all the help

<table cellpadding="0" cellspacing="0" border="0" width="181">
<tr class=siteNavTD><td valign="top" height="20"></td><td width="100%">Search</td>
<td valign="top"></td>
</tr></table>
<table cellpadding="0" cellspacing="0" border="0" width="181">
<tr><td colspan="3" class=siteNav3TD>
<input type="text" name="edtSearchWords" value="<%=Request.Form("edtSearchWords")%>" size="11" style="font-family: Verdana; font-size: 8pt" maxlength="16"> <% If objThirdParty.Count > 0 Then%>IN<%End if%>
<% If objThirdParty.Count > 0 Then%>
</td></tr>
<tr><td colspan="3" class=siteNav3TD>
thanx

There are many tutorials available. you will want to find ones specific for your programming language and your particular database. Again, I have no idea what type of database you are using, so I can't provide any suggestions.
Michael J

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |