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 9207123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:19:15+00:00 2026-06-18T00:19:15+00:00

Does anyone have any experience in creating their own AJAX auto suggest text box

  • 0

Does anyone have any experience in creating their own AJAX auto suggest text box with full keyboard support?

I have successfully created the auto suggest aspect by plugging in to a SQL DB and displaying results but the only way to interact with the search results is to use the mouse. I want to be able to scroll up/down with the keyboard and use the enter key to select the item and be redirected to the relevant page.

I have seen countless articles and help forum pages detailing how to scroll through HTML elements with the up/down arrows, but nothing explaining how the enter key can be incorporated into selecting the item and redirecting to the relevant page.

I am aware of all the auto suggest plugins I can use, but I have come this far creating my own and I want to be able to add extra content to the results rather than be fixed to someone else’s work.

If anyone could help me out by pointing me in the right direction I would be very grateful.

Cheers

  • 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-06-18T00:19:16+00:00Added an answer on June 18, 2026 at 12:19 am

    This answer definitely falls under the category ‘point in the right direction’, because I don’t know if you already have code and what that looks like (if it exists).

    You said you already created a dropdown with suggestions, so I’ll leave out CSS and JS for styling and positioning.
    Let’s assume the dropdown consists of this markup:

    <div id="suggestiondropdown">
        <span class="suggestion" data-page="[URL of page]">Suggestion 1</span>
        <span class="suggestion" data-page="[URL of page]">Suggestion 2</span>
        <span class="suggestion" data-page="[URL of page]">Suggestion 3</span>
        <span class="suggestion" data-page="[URL of page]">Suggestion 4</span>
        <span class="suggestion" data-page="[URL of page]">Suggestion 5</span>
    </div>
    

    With this JS you should be able to move between the suggestions with the arrow keys:

    var suggestions = document.querySelectorAll(".suggestion"); // Now suggestions is an array with the spans
    var index = 0;
    document.onkeypress = function(e) {
        // Style the selected as normal here:
        suggestions[index].style.backgroundColor = "#FFFFFF";
        if (e.keyCode == 38) { // UP!
            if (index <= 0) index = suggestions.length;
            index--;
        }
        else if (e.keyCode == 40) { // DOWN!
            if (index >= suggestions.length -1) index = -1;
            index++;
        }
        else if (e.keyCode == 13) { // ENTER!
             var page = suggestions[index].dataset.page;
             window.location.href = page; // Or with relative URLs, first prepend the base URL.
        }
        // Style the selected one as selected here.
        // I don't know how you want it, so I'll just give the selected one a blue background.
        suggestions[index].style.backgroundColor = "#0000FF"; // Never mind the ugly shade
    
    }
    

    Untested

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have any experience creating a skin engine for asp.net MVC? I know
Does anyone have any experience with creating database agnostic apps in Java, particularly with
I'm using Codeigniter 1.7. Does anyone have any experience of creating web services with
Does anyone have any experience in using compression on their cached data? I understand
Does anyone have any experience querying FlexLM? (At a minimum) I need to be
Does anyone have any experience using PHP to send an sms via skype I
Does anyone have any experience with the following fluent config error? faultString = An
Does anyone have any experience with doing mail merge from Java on a word
Does anyone have any experience of storing data in JavaScript across all mobile platforms
Does anyone have any experience with this sort of thing? I'm talking about applets

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.