Solved

Creating search boxes

Posted on 2002-07-24
5
130 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now