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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:02:37+00:00 2026-06-12T17:02:37+00:00

This includes a sample code from a previous question IndexedDB Fuzzy Search . How

  • 0

This includes a sample code from a previous question “IndexedDB Fuzzy Search“.
How can I bound the cursor result to a input box to create a auto-complete effect and fill multiple input boxes of a form with the different values from the objectStore when a result is chosen? I would like to do this without any libraries.

The HTML input boxes.

 <input name="name" id="name"> //search by name, when a name is selected the last name and age are automatically attached to the other input boxes
 <input name="lastname" id="lastname">
 <input name="age" id="age">

The Javascript.

var result = [];
db.transaction(['table'], IDBTransaction.READ_ONLY)
.objectStore('table')
.openCursor(
IDBKeyRange.bound(searchTerm, searchTerm + '\uffff'),
IDBCursor.PREV)
.onsuccess = function (e) {
    e || (e = event);
    var cursor = e.target.result;
    if (cursor) {
        result.push([cursor.value.column1, cursor.value.sortcolumn]);
        cursor.continue();
    } else {
        if (result.length) {
        result.sort(function (a, b) {
         return a[1] - b[2];
      });
    }

    // Process code here
    }
};
  • 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-12T17:02:38+00:00Added an answer on June 12, 2026 at 5:02 pm

    Well, in your case you might only want the first result that cursor return, so you just need to check is there a result returned, something like this:

    <input name="name" id="name">
    <input name="lastname" id="lastname">
    <input name="age" id="age">
    <script>
    document.getElementById('name').oninput = function () {
      var searchTerm = this.value;
    
      var result = [];
      db.transaction(['table'], IDBTransaction.READ_ONLY)
        .objectStore('table')
        .openCursor(
          IDBKeyRange.bound(searchTerm, searchTerm + '\uffff'), // The important part
          IDBCursor.PREV)
        .onsuccess = function (e) {
          e || (e = event);
          var cursor = e.target.result;
          if (cursor) {
            // Here I assume that your table with 'lastname' and 'age'
    
            // Return result to "lastname" input
            document.getElementById('lastname').value = cursor.value.lastname;
    
            // Return result to "age" input
            document.getElementById('lastname').value = cursor.value.age;
          }
        };
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code sample for my question: IList<TestDataAnimal> testDataFromDb = this.db.TestDataAnimals.Include(t => t.TestType).Include(t => t.Visit).Include(t =>
I need to change a piece of code which includes this: string.indexOf(bc) How can
All, I'd like to understand I'm looking at this code sample from w3Style's front
Most of the sample code from Microsoft's DirectX SDK includes variables which use the
Given this sample code: #include <iostream> #include <stdexcept> class my_exception_t : std::exception { public:
Can anybody help me with this simple code?? #include <iostream> using namespace std; void
My code looks somehow like this: //INCLUDES FILE *file; void handlesocket(int socket); int main(int
This question is similar to my previous question but not the same ... please
This question is in continuation to my previous post located here . Since there
I downloaded some sample code which includes a database query within the markup code.

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.