Solved

Creating search boxes

Posted on 2002-07-24
5
132 Views
Last Modified: 2013-12-23
I have an employee table with first, last & middle name. I need to create a search box where the user will enter part of the last name and all available matches (Last, First, M) will appear in a box. Then the user should be able to select one of the names to query for information.

Example:

User enters
"Jone"

Interdev returns
"Jones, Ben R."
"Jones, Raymond Q."
"Jones, Stacy M."

User clicks on "Jones, Raymond Q." and the main info screen appears for that employee.

Thanks in advance for your help!
0
Comment
Question by:StacyWest
5 Comments
 
LVL 19

Accepted Solution

by:
DreamMaster earned 75 total points
ID: 7188207
That doesn't seem so hard..

All you do is create a query that fills the listbox.

Something like this:

sSQL = "SELECT ID, Lastname, Firstname from tblEmployee where Lastname like '%" & Request.Form("inpSearchTxt") & "%'"

This inpSearchTxt comes from a textfield with that name.

So your form will look like this initially:

<form name="frmEmployeeSearch" action="EmployeeSearch.asp" method="post">
  <input type="textbox" name="inpSearchTxt">
  <input type="submit" name="inpSubmit" value="Search">
  ...
</form>

Now to make the populated listbox appear when you have send the query... fill in the following at the dots:

<%
  If (Request.Form("inpSearchTxt") <> "") then
%>
  <select name="selEmployees" onchange="location.href=this[this.selectedIndex].value">
<%
   ' Your routines for opening the database go here.
   sSQL = "Select ID, Lastname, Firstname from tblEmployee where Lastname like '%" & Request.Form("inpSearchTxt") & "%'"
   Set rs=DB.Execute (sSQL)
   if not (rs.eof and rs.bof) then
     do while not rs.eof
      %>
      <option name="<%= rs("Lastname") & "-" & rs("Firstname") %>" value="employeedetails.asp?id=<%=rs("ID")%>"><%= rs("Lastname") & ", " & rs("Firstname") %></option>
      <%
       rs.movenext
     loop
    end if
%>
  </select>
<%
  end if
%>

Good luck, I hope this points you in the right direction...

Max.
0
 
LVL 1

Expert Comment

by:worldspawn
ID: 7296591
What exactly does this have to do with interdev?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question