Solved

Creating search boxes

Posted on 2002-07-24
5
129 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
Comment Utility
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
Comment Utility
What exactly does this have to do with interdev?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
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 insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

744 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

16 Experts available now in Live!

Get 1:1 Help Now