Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 201699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:13:20+00:00 2026-05-11T17:13:20+00:00

and thanks for reading. I am building a data entry form. I am trying

  • 0

and thanks for reading.

I am building a data entry form. I am trying to figure out a way to let the user to provide a criteria (last name for instance), search the employee table for all employees that match the criteria, display the result in a way they can select the correct employee, and pass the the ID of that employee back to the data entry form so they can complete the record and save it.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:13:20+00:00Added an answer on May 11, 2026 at 5:13 pm

    One way to do this would be with the jQuery autocomplete plugin. Have text box on your form that allows search and a hidden field that stores the id. Use autocomplete via AJAX to get a list of name/id pairs returned as JSON based on the search criteria. Have the autocomplete set up to force selection from the list — which will disallow any non-matching text in the field. When the user selects an item from the list have the result function store the associated id in the hidden field. Use the hidden field on form post to get the ID of the employee.

    It might look something like:

    View

    $('#searchBox').autocomplete( '/Employees/Search', {
        dataType: 'json',
        max: 25,
        minChars: 2,
        cacheLength: 1,
        mustMatch: true,
        formatItem: function(data,i,max,value) {
            return value;
        },
        parse: function(data) {
            var array = new Array();
            for (var i=0; i < data.length; i++) {
                var datum = data[i];
                var display = datum.FirstName + ' ' + datum.LastName;
                array[array.length] = { data: datum, value: display, result: display };
            }
        }
    });
    
    $('#searchBox').result( function(event, data, formatted) {
        if (data) {
           $('#employeeID').val( data.EmployeeID );
        }
    });
    
    $('form').submit( function() {
        if (!$('#employeeID').val()) {
           alert( 'You must select an employee before clicking submit!' );
           return false;
        }
    });
    
    
    <input type='text' id='searchBox' />
    <input type='hidden' id='employeeID' name='employeeID' />
    

    Controller:

    public ActionResult Search( string q, int limit )
    {
        var query = db.Employees.Where( e => e.LastName.StartsWith( q ) )
                                .OrderBy( e => e.LastName )
                                .Select( e => new
                                     {
                                         FirstName = e.FirstName,
                                         LastName = e.LastName,
                                         EmployeeID = e.EmployeeID
                                 });
        if (limit > 0)
        {
            query = query.Take(limit);
        }
    
        return Json( query.ToList() );
    }
    
    public ActionResult SomeAction( int employeeID, ... )
    {
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a WinForms application reading from a socket data and charting lines.
I am building a tool. I have a Collection Class that stores data gathered
I am currently reading Pro Asp.Net MVC, and they are building all of their
I am reading a postfix mail log file into an array and then looping
I'm building an app which is going to have to handle and store a
My app generates SSIS packages for importing data from Excel files. This is done
Alright, so I'm building a web app that provides music information (i.e. info on
I have an access table with an automatic primary key, a date, and other
I USED to be a developer and part-time db designer, but it's been many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.