I'm trying to make a search function for my database. Right now I'm working on a very simple version where the user inputs a number into a form and the results page is supposed to show the same numebr from the form. For some reason the results page will only display the default number no matter what I input into the search form. Here is the code for my recordset and the two pages. Can someone help me figure out what I'm doing wrong?
Recordset (on results page) <<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<
<<<<<<<<<<
<<<<<<<
SELECT ID, item, store, address, description
FROM shoppinglist
WHERE ID = MMColParam
name default value run-time value
MMColParam 1 Request.QueryString("searc
htest")
search page code <<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<
<<<<<<<<<<
<<<<<<<<<<
<<<<<
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="searchtest" name="searchtest" method="post" action="results.asp">
<label>
Search
<input type="text" name="textfield" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
</body>
</html>
Results page<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<
<<<<<<<<<<
<<<<<<<<<<
<<<<<<<<
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/consearc
htest.asp"
-->
<%
Dim rssearchtest__MMColParam
rssearchtest__MMColParam = "1"
If (Request.QueryString("sear
chtest") <> "") Then
rssearchtest__MMColParam = Request.QueryString("searc
htest")
End If
%>
<%
Dim rssearchtest
Dim rssearchtest_numRows
Set rssearchtest = Server.CreateObject("ADODB
.Recordset
")
rssearchtest.ActiveConnect
ion = MM_consearchtest_STRING
rssearchtest.Source = "SELECT ID, item, store, address, description FROM shoppinglist WHERE ID = " + Replace(rssearchtest__MMCo
lParam, "'", "''") + ""
rssearchtest.CursorType = 0
rssearchtest.CursorLocatio
n = 2
rssearchtest.LockType = 1
rssearchtest.Open()
rssearchtest_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="500" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>test number </td>
</tr>
<tr>
<td><%=(rssearchtest.Field
s.Item("ID
").Value)%
></td>
</tr>
</table>
</body>
</html>
<%
rssearchtest.Close()
Set rssearchtest = Nothing
%>
try this for your form:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="searchtest" name="searchtest" method="post" action="results.asp">
<label>
Search
<input type="text" name="searchtest" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
</body>
</html>
You need to give your text field the name searchtest
<input type="text" name="searchtest" />
Thanks
Jay Eire