PDA

View Full Version : quick search won't work! please help


mazer
10-03-2005, 06:04 PM
I have a quick search on my site and it wont work any more and I cant figure out what is wrong with it? the search uses two check boxes, one for cards and one for comics and all the info is in an access bd with two tables. I'm totally new to all this so I cant figure out what I did wrong
here is the form
<TD ALIGN="CENTER" HEIGHT="89" WIDTH="330"><font size="4" font color="#FF0000"><b>Quick Search of our Inventory</b></font>
<FORM NAME="searchform" ACTION="./html/quick_search_results.asp" METHOD="get">
<INPUT TYPE=TEXT NAME="searchvalue" VALUE="" SIZE=18 MAXLENGTH=26>
<INPUT TYPE=SUBMIT NAME="search" VALUE="Search"><br>
<INPUT TYPE=CHECKBOX NAME="card" onClick="uncheckcomic()"><FONT COLOR="#FFFFFF">Cards</FONT>
<INPUT TYPE=CHECKBOX NAME="comic" onClick="uncheckcard()"><FONT COLOR="#FFFFFF">Comics</FONT><BR>
</FORM>
</TD>
The query string is
<script>
<!--
function uncheckcomic(){
document.searchform.comic.checked=false
}
function uncheckcard(){
document.searchform.card.checked=false
}
-->
</script>

CAN SOMEONE PLEASE HELP ME WITH THIS, I'M TOTALLY CRACKING UP TRYING TO FIGURE THIS OUT

Brandoe85
10-03-2005, 06:42 PM
What doesn't work? What's it suppose to do? Post the asp code.

TheShaner
10-03-2005, 06:45 PM
Well, first, the form seems fine.

Second, what problem are you having? What error is being generated? Is it going to the next page? Is it that no results are being returned?

Third, your onClick event is a little haywired. I'm not sure if you error check in your ASP code, but just to be sure, one of the checkboxes should be checked by default. Then you should have it where checking one unchecks the other. HOWEVER, your onClick event is triggered when you UNCHECK a checkbox also!

So do this:
<TD ALIGN="CENTER" HEIGHT="89" WIDTH="330">
<font size="4" font color="#FF0000"><b>Quick Search of our Inventory</b></font>
<FORM NAME="searchform" ACTION="./html/quick_search_results.asp" METHOD="get">
<INPUT TYPE=TEXT NAME="searchvalue" VALUE="" SIZE=18 MAXLENGTH=26>
<INPUT TYPE=SUBMIT NAME="search" VALUE="Search"><br>
<INPUT CHECKED TYPE=CHECKBOX NAME="card" onClick="checkcard()"><FONT COLOR="#FFFFFF">Cards</FONT>
<INPUT TYPE=CHECKBOX NAME="comic" onClick="checkcomic()"><FONT COLOR="#FFFFFF">Comics</FONT><BR>
</FORM>
</TD>
Then your JavaScript as:
<script language="JavaScript">
<!--
function checkcard()
{
if document.searchform.card.checked
document.searchform.comic.checked = false
else
document.searchform.comic.checked = true
}
function checkcomic()
{
if document.searchform.comic.checked
document.searchform.card.checked = false
else
document.searchform.card.checked = true
}
-->
</script>
On a side note, the code you posted (not your form code) is your script on your webpage, not your query string. You query string is what is generated from your form's submission that is displayed after quick_search_results.asp in your address bar.

-Shane

mazer
10-03-2005, 07:01 PM
The page wont load when I search for an item, I get an http 500 error, it was working fine but I made some alterations to the site and after that it just wouldn't work

<% @LANGUAGE = VBScript %>
<% Option Explicit %>

<%
Dim thumbs(7), text(20), pagenos, info, image
Dim search, uid, pagenumber, colour, rarity, productset, producttype
Dim strQuery, objRS, objConn, filePath
Dim i, number, remainders
Dim pages, table, desc, code, price, instock, details
Dim itemtype

search = Request.QueryString("searchvalue")
uid = Request.QueryString("uid")
pagenumber = Request.QueryString("pagenumber")

Set objConn = Server.CreateObject("ADODB.Connection")
filePath = Server.MapPath("..\database.mdb")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath

If Request.QueryString("comic") = "on" Then
table = "Comics"
itemtype = "comic"
ElseIf Request.QueryString("card") = "on" Then
table = "Cards"
itemtype = "card"
Else
table = "Cards"
itemtype = "card"
End If

If pagenumber = "" Then
pagenumber = 1
End If

If search = "" Then
pagenos = ""
info = ""
image = "..\blackblank.gif"
For i = 0 to 20
'thumbs(i) = ""
text(i) = ""
Next
Else
strQuery = "SELECT Thumbs, ProductName, Description, UID FROM " & table & " WHERE ProductName LIKE '%" & search & "%';"
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open strQuery,objConn,3,3

If NOT objRS.EOF Then
number = objRS.recordcount
pages = number / 20
pages = fix(pages)
remainders = number MOD 20
If remainders = 0 Then
Else
remainders = 1
End If
pagenos = ""
If pages > 50 Then
pagenos = "<P ALIGN=CENTER><FORM METHOD=GET ACTION=" & Request.ServerVariables("SCRIPT_NAME") & ">"
pagenos = pagenos & "<INPUT TYPE=HIDDEN NAME=searchvalue VALUE=" & search & ">"
pagenos = pagenos & "<INPUT TYPE=HIDDEN NAME=card VALUE=" & Request.QueryString("card") & ">"
pagenos = pagenos & "<INPUT TYPE=HIDDEN NAME=comic VALUE=" & Request.QueryString("comic") & ">"
pagenos = pagenos & "<SELECT SIZE=6 NAME=pagenumber onchange=this.form.submit()>"
For i = 1 to (pages + remainders)
pagenos = pagenos & "<OPTION"
If i = cint(pagenumber) Then
pagenos = pagenos & " SELECTED"
End If
pagenos = pagenos & ">" & i & "</OPTION>"
Next
pagenos = pagenos & "</SELECT></FORM></P>"
ElseIf pages > 10 Then
For i = 1 to (pages + remainders)
If i mod 20 = 0 Then
pagenos = pagenos & "<BR>"
End If
pagenos = pagenos & "<A HREF=" & Request.ServerVariables("SCRIPT_NAME")
pagenos = pagenos & "?searchvalue=" & search & "&pagenumber="
pagenos = pagenos & i & "&card=" & Request.QueryString("card")
pagenos = pagenos & "&comic=" & Request.QueryString("comic") & ">" & i & "</A>&nbsp"
Next
Else
For i = 1 to (pages + remainders)
pagenos = pagenos & "<A HREF=" & Request.ServerVariables("SCRIPT_NAME")
pagenos = pagenos & "?searchvalue=" & search & "&pagenumber="
pagenos = pagenos & i & "&card=" & Request.QueryString("card")
pagenos = pagenos & "&comic=" & Request.QueryString("comic") & ">" & i & "</A>&nbsp"
Next
End If

i = 0
While( i < ( (pagenumber - 1) * 20) )
objRS.MoveNext
i = i + 1
Wend
uid = objRS("uid")
For i = 0 to 20
If NOT objRS.EOF Then
text(i) = "<A HREF=" & Request.ServerVariables("SCRIPT_NAME")
text(i) = text(i) & "?uid=" & objRS("UID") & "&searchvalue="
text(i) = text(i) & Server.URLEncode(search) & "&pagenumber="
text(i) = text(i) & pagenumber & "&card=" & Request.QueryString("card")
text(i) = text(i) & "&comic=" & Request.QueryString("comic") & "><FONT COLOR=#FFFFFF>"
text(i) = text(i) & objRS("ProductName")
If table = "Comics" Then
text(i) = text(i) & " " & objRS("Description")
End If
text(i) = text(i) & "</FONT></A>"
objRS.MoveNext
End If
Next
End If
End If

If Request.QueryString("uid") <> "" Then
uid = Request.QueryString("uid")
End If

strQuery = "SELECT * FROM " & table & " WHERE UID='" & uid & "';"
Set objRS = objConn.Execute(strQuery)
If NOT objRS.EOF Then
image = objRS("Images")
info = "<P ALIGN=CENTER>"
info = info & objRS("ProductName") & "<BR>" & objRS("ProductType") & "<BR>"
info = info & objRS("Description") & "<BR>"
If table = "Cards" Then
info = info & "Rarity " & objRS("Rarity") & "<BR>"
ElseIf table = "Comics" Then
info = info & "Grade " & objRS("Grade") & "<BR>"
Else
info = info & "Rarity " & objRS("Rarity") & "<BR>"
End If
info = info & "€" & FormatNumber(objRS("UnitPrice"), 2) & "<BR></P>"
desc = objRS("ProductName")
price = objRS("UnitPrice")
code = objRS("UID")
instock = objRS("UnitsInStock")
details = objRS("ProductName") & "-" & objRS("Description") & "-" & objRS("Grade") & "" & objRS ("Rarity")
End If

objConn.Close
%>

neocool00
10-03-2005, 08:00 PM
@mazer,
Ok, to see what error is being thrown, in IE, go to Tools-->Internet Options. Then click on "Advanced" tab. Scroll down a bit until you see "Show friendly HTTP error messages". Uncheck the box and click "Ok", then hit your page again. You shoud see some type of ASP error. I'm wondering if your action on your form is what's causing the problem. I don't think you can use "./" as part of the action for a form, but I could be wrong. Also, if you want users to choose one choice or another, you could use a radio button instead of checkboxes, then you wouldn't need Javascript to uncheck the other box if the select the second one. Just an FYI.

mazer
10-03-2005, 09:33 PM
this is the error that I get now!

Microsoft JET Database Engine error '80040e10'

No value given for one or more required parameters.

/html/quick_search_results.asp, line 43

glenngv
10-04-2005, 04:23 AM
What is line 43? :rolleyes:

mazer
10-04-2005, 01:57 PM
If search = "" Then
pagenos = ""
info = ""
image = "..\blackblank.gif"
For i = 0 to 20
'thumbs(i) = ""
text(i) = ""
Next<!--line 43-->
Else
strQuery = "SELECT Thumbs, ProductName, Description, UID FROM " & table & " WHERE ProductName LIKE '%" & search & "%';"
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open strQuery,objConn,3,3

mazer
10-04-2005, 02:15 PM
I got it working again, I had removed the thumbs field from the database because I don't use thumbs any more, this was causing the problem because the asp script still searchs for the thumbs field! Thanks for all the help.