Computing.Net > Forums > Web Development > very strange search box

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

very strange search box

Reply to Message Icon

Name: neonwill
Date: February 27, 2008 at 06:42:54 Pacific
OS: xp
CPU/Ram: 1GB
Product: Dell
Comment:

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 here

document.Mainsearch.submit();
return true;
}
</script>

<%

Function search_FormatString(strName)
Dim m_Name, m_Temp

m_Name = UCase(Mid(strName,1,1)) & LCase(Mid(strName,2))
m_Temp = 0

While 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



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: February 27, 2008 at 10:17:43 Pacific
Reply:

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


0

Response Number 2
Name: neonwill
Date: February 27, 2008 at 11:13:01 Pacific
Reply:

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


0

Response Number 3
Name: neonwill
Date: February 27, 2008 at 11:23:59 Pacific
Reply:

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


0

Response Number 4
Name: Michael J (by mjdamato)
Date: February 27, 2008 at 13:06:13 Pacific
Reply:

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


0

Response Number 5
Name: neonwill
Date: February 27, 2008 at 13:10:54 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Michael J (by mjdamato)
Date: February 27, 2008 at 15:15:09 Pacific
Reply:

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


0

Response Number 7
Name: neonwill
Date: February 28, 2008 at 06:23:03 Pacific
Reply:

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>


0

Response Number 8
Name: neonwill
Date: February 28, 2008 at 06:28:45 Pacific
Reply:

<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


0

Response Number 9
Name: Michael J (by mjdamato)
Date: February 28, 2008 at 07:59:59 Pacific
Reply:

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


0

Response Number 10
Name: neonwill
Date: February 28, 2008 at 08:48:41 Pacific
Reply:

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


0

Response Number 11
Name: neonwill
Date: February 28, 2008 at 10:11:17 Pacific
Reply:


<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


0

Response Number 12
Name: Michael J (by mjdamato)
Date: February 28, 2008 at 11:19:55 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: very strange search box

search box problem www.computing.net/answers/webdevel/search-box-problem/3520.html

PHP Search text box www.computing.net/answers/webdevel/php-search-text-box/1741.html

Access - web search www.computing.net/answers/webdevel/access-web-search/1144.html