Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

providing a search by two drop down menu's containing variables ;o

Status
Not open for further replies.

gavray

Programmer
Jul 17, 2000
65
GB
Hi, this is a tricky one, ;O

I can successfully provide a search for say 'region' but when trying to combine this with a search for say 'industry' at the same time. e.g 'region' louisiana 'jobs' health care. I'd be really gratefull cause I've been surfing all day for an answer. Thanks

It gives me the error

Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: "SELECT JobTable.Comp"]'

/industrysearchregion.asp, line 19

the code is as follows

form-

<html>
<head>
<title>Untitled</title>
</head>

<body>
<%
Dim oRSv
Set oRSv=Server.CreateObject(&quot;adodb.Recordset&quot;)
oRSv.Open &quot;IndustryTable&quot;, &quot;dsn=50on&quot;
oRSv.MoveFirst
%>

<form method=&quot;post&quot; action=&quot;industrysearchregion.asp&quot;>
<h5>Select region</h5>

<input type=&quot;submit&quot; value=&quot;search&quot;>
<select name=&quot;industry&quot; size=&quot;1&quot;>

<%

Do While NOT oRSv.EOF
Response.Write &quot;<option value='&quot; & oRSv(&quot;industry&quot;) & &quot;'>&quot;
Response.Write oRSv(&quot;industry&quot;) & &quot;</option>&quot;
oRSv.MoveNext
loop
oRSv.Close
Set oRSv=nothing
%>
</select>
<%
Dim oRSr
Set oRSr=Server.CreateObject(&quot;adodb.Recordset&quot;)
oRSr.Open &quot;RegionTable&quot;, &quot;dsn=50on&quot;
oRSr.MoveFirst
%>

<h5>Select region</h5>
<input type=&quot;hidden&quot;>
<select name=&quot;region&quot; size=&quot;1&quot;>

<%
Do While NOT oRSr.EOF
Response.Write &quot;<option value='&quot; & oRSr(&quot;region&quot;) & &quot;'>&quot;
Response.Write oRSr(&quot;region&quot;) & &quot;</option>&quot;
oRSr.MoveNext
loop
oRSr.Close
Set oRSr=nothing
%>
</select>

</body>
</html>

response page-

<html>
<head>
<title>search a job</title>
</head>
<body>

<%
varindustry=Request.Form(&quot;industry&quot;)
varregion=Request.Form(&quot;region&quot;)
Dim oRS2
dim iRowCounter
Set oRS2=Server.CreateObject(&quot;adodb.Recordset&quot;)

sSQL=&quot;SELECT JobTable.Company, JobTable.industry, JobTable.Jobtitle, JobTable.region&quot;
sSQL=sSQL & &quot; FROM JobTable&quot;
sSQl=sSQL & &quot; WHERE region='&quot; & varregion & &quot;'&quot;
sSQL=sSQL & &quot;'&quot; AND &quot;WHERE industry='&quot; & varindustry & &quot;'&quot;
sSQL=sSQL & &quot; ORDER BY JobTable.Jobtitle;&quot;


oRS2.open sSQL, &quot;DSN=50on&quot;

if oRS2.EOF=True then
Response.write (&quot;Sorry, no jobs were found in this sector&quot;)

else oRS2.MoveFirst

response.write &quot;<table bgcolor=Silver valign=top width=500 bordercolordark=Gray border=0>&quot;

response.write &quot;<th bgcolor=white> Job title </th>&quot; & &quot;<th bgcolor=white> Industry </th>&quot; & &quot;<th bgcolor=white>Company</th>&quot; & &quot;<th bgcolor=white> Region </th>&quot;


Do while Not oRS2.EOF
''<a href='&quot; & oRS2 (&quot;ID&quot;) & &quot;'>
Response.Write &quot;<tr><td>&quot; & oRS2 (&quot;Jobtitle&quot;) & &quot;</td>&quot;
Response.Write &quot;<td>&quot; & oRS2 (&quot;industry&quot;) & &quot;</td>&quot;
response.write &quot;<td>&quot; & oRS2 (&quot;Company&quot;) & &quot;</td>&quot;
response.write &quot;<td>&quot; & oRS2 (&quot;region&quot;) & &quot;</td></tr>&quot;

oRS2.MoveNext

Loop
end if
oRS2.Close
set oRS2=Nothing
response.write &quot;</table>&quot;
%>

</font>
</body>
</html>

cheeeeers!

Gavin
 
In your response page, the following line:
Code:
sSQL=sSQL & &quot;'&quot; AND &quot;WHERE industry='&quot; & varindustry & &quot;'&quot;
should be:
Code:
sSQL=sSQL & &quot; AND WHERE industry='&quot; & varindustry & &quot;'&quot;
You might also want to rethink the way you're building your SQL statement. What happens if someone leaves 'region' blank and only enters 'industry'? You'd most probably return no records.

Choo Khor
choo.khor@intelebill.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top