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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:03:42+00:00 2026-05-29T08:03:42+00:00

Ok, this is a multipart concept. However I’m sure if I can figure this

  • 0

Ok, this is a multipart concept. However I’m sure if I can figure this piece out, the rest will follow.

What I have is an array of Words and Phrases. And I have a TextArea where people can type in. What I want to do is be able to search the array for matches or similarities in what the user is typing. The closest thing I can think of is an auto complete function. But thats not entirely what I want, yes in part what I want is an auto completes functionality, but so much more in the end run that an existing auto complete is a bit bulky for my needs.

What my Aim is, is after the user hits the spacebar is to trigger the search as they type. Now up to this point I am good. My issue is my logic is flawed from here. I want to be able to take the entire boy of text up to the point of hitting the spacebar and check it against my array of words and phrases. But Im not sure how. Currently I am split() on the textarea itself where space is my split() delimiter, but I realize now that thats not right. What I was thinking initially was split it, check it against the other array and it would be a happy day if something matched, then I realized I have phrases, if I am trying to check a phrase for a match then I wont match one.

Well hopefully this makes sense. I need to walk through logic on this, there really isnt code currently, as I am not debugging, I am trying to figure out a logic to work with that works. So I can move forward.

  • 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-29T08:03:43+00:00Added an answer on May 29, 2026 at 8:03 am

    UPDATE:

    Check this fiddle: http://jsfiddle.net/VwNHN/

    You will need to tweak it to your requirements, but it will give a fair idea of how the below logic can be implemented.


    Well, the logic upon keypress (probably any key and not just spacebar) can be something like:

    1) Get your current cursor position – say X
    Refer for example: http://demo.vishalon.net/getset.htm

    2) Get N characters to the left of X. i.e. a substring of the whole text from index X-N to X – store it in Y. You will need to fix on a value for N (for ex: 100). N is the longest word/phrase you are looking to match.

    ex: if full text is "hello world i am a sentence", and cursor is at the end, and N is 10, Y would be "a sentence"

    3) Split Y by space character and store each split in an array incrementally and then reverse it – lets call the array PHRASES

    ex: if Y is "this is a sentence" – then PHRASES would be

    [ "this is a sentence", "this is a", "this is", "this" ]
    

    4) Check your array of words/phrases with each item in the PHRASES – the longest matching parts will come first and the short matching ones will come last – this set of matches is your auto-complete list.

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

Sidebar

Related Questions

This problem has been bugging me since forever. I have an array and in
I have set the enctype to: multipart/form-data yet whenever I submit this form, the
I currently have a form like this: <% form_for @stem, :html => {:multipart =>
I have a raw email, (MIME multipart), and I want to display this on
I have this form: <form name=commentform id=commentform action=comment.php method=post enctype=multipart/form-data> Your Name: <textarea maxlength=60
I have this form: <form action=image_upload.php method=post enctype=multipart/form-data> Image 1: <input type=file name=event_image />
I have this code (like in Spring's reference): <bean id=multipartResolver class=org.springframework.web.multipart.commons.CommonsMultipartResolver> <!-- one of
I have a multipart string like this: String Y = part1 part2 part3 part4;
I follow this tutorial to parse multipart request. To this code in first line
This is what I have: <form name=myts method=post action=ts.php enctype=multipart/form-data onsubmit=return upuInit(this)> . .

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.