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!

filter returned DB values using textbox

Status
Not open for further replies.

ermutigen

MIS
Apr 6, 2006
7
US
I am very new to this and need a little help. I have a webform that will query a DB and return all values. I want to add a textbox so that users can use wildcards to narrow down the results that are returned. I am unsure how to get the value that is entered into the textbox to be added to the query. Here is part of what I have so far. Any help would be greatly apprciated! Thanks -e

Code:
<form action="time_to_project_by_project_number-dynamic.asp" method="POST" name="parmform">
<table border="1">

  <tr>
    <td>Project Number Search:</td>
    <td>
    <input id="txtSearch" type="text" />
    <input id="btnSearch" type="button" value="Search" />
    </td> 
  </tr>

  <tr>
    <td>Select Project Number(s):
    </td>
    <td>
<%
parmid = "P1"
provider = "MSDASQL"
datasource = "database"
username = "name"
password = "password"
databasetable = "TRANSACT"
valuedatabasecolumn = "ENTITY_NUM"

strConn = "Provider=" & provider & ";Data Source=" & datasource & ";User ID=" & username & ";password=" & password & ";"

query = "SELECT DISTINCT " & valuedatabasecolumn & "," & valuedatabasecolumn & " || ' - ' || description "
query = query & " FROM " & databasetable
query = query & " where POST_DATE >= to_date('01/01/2007', 'MM/DD/YYYY')"

set conn = Server.CreateObject("ADODB.Connection")
conn.Open strconn
set rs = conn.Execute( query )

     Response.Write("<SELECT SIZE=15 NAME=" & chr(34) & parmid  & chr(34) & " MULTIPLE>" & chr(13) )
     rs.movefirst
     do while not rs.EOF
         if rs(0) <> "" then
             Response.Write( "<OPTION VALUE=" & chr(34) & rs(0) & chr(34) & ">" & rs(1) & chr(13) )
         end if
         rs.movenext
     loop
     Response.Write("</SELECT>")
 
rs.close
set rs = nothing
set conn = nothing
%>
                   
    </td>
  </tr>
 
Server-side it is this.
[tt] txtSearch=request.form("txtSearch")[/tt]
Client-side it is this.
[tt] txtSearch=document.parmform.txtSearch.value[/tt]
 
Thanks tsuji. But where do I add this to my code and what gets added to the query?

thanks,
e
 
Where indeed. But, the shown script is not a starting level script, and by the time you can write those, you should already have a good idea where to put and what mechanism it is involved. The answer can only be given by yourself with all the application design on hand.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top