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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search in ASP

Status
Not open for further replies.

Tarzan613

Programmer
Jun 10, 2002
10
0
0
US
Hi All!
I'm new to asp and I have a question..

I have table in SQl 7.0 and and with ASP I made a connection with this table.. In internet Explore I created drop down box and in this drop down box there is an information (records) from this table..
When I'm choosing on of them it goes to a linked that i specifyed..

My question how to create a field where I can write a Company Name (Companies names are in my table) and then click search and the specific company that I will choose in search will display in this drop down box..
P.S. In this drop down box I have 10000 records...
 
First of all, you can do this.

Secondly, it actually has to be done on the database side.


Say that right now you are building your drop down off the select statement.

set Conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open (provider string)
SQL = "Select company_name from companies"
RS.open SQL, conn

<select size=1 name=company>
<%
do until rs.eof
response.write (&quot;<option value=&quot; & rs(&quot;company_name&quot;) & &quot;>&quot; & rs(&quot;company_name&quot;) & &quot;</option>&quot; & Chr(13))
rs.movenext
loop

%>
</select>


So what you do is build a simple text field in a separate form, and it takes in the value and passes it to the SQL statement.


<form action=&quot;&quot; method=post>
<input type=company_name>
<input type=submit value=&quot;Search&quot;>
<input type=reset value=&quot;Reset&quot;>
</form>

then you change the SQL statement above to

if request.form(&quot;company_name&quot;) <> &quot;&quot; then
strname = &quot;where company_name like '%&quot; & request.form(&quot;company_name&quot;)& &quot;%';&quot;
'-- This is so that partial company names will display as '--well as exact matches.


else
strname =&quot;&quot;
end if

SQL = &quot;Select Company_name from companies &quot; & strname


This way,when you have a value in the search box, and you submit it changes the SQL statement that populates the drop down box.....

The money's gone, the brain is shot.....but the liquor we still got.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top