[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating search boxes

Posted on 2002-07-24
5
Medium Priority
?
139 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
2 Comments
 
LVL 19

Accepted Solution

by:
DreamMaster earned 300 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
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…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
Suggested Courses
Course of the Month17 days, 14 hours left to enroll

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