10

Is there a jQuery plugin that suggests/autocompletes within a textarea?

What I want is to have suggested words or autocompleted text proffered to the user in a textarea like the example image below:

autocomplete box demo

Vlad
  • 9,180
  • 5
  • 48
  • 67
Trufa
  • 39,971
  • 43
  • 126
  • 190

4 Answers4

4

Well there is the autocomplete plugin that does just that, and if you want to pull data from a database I recomment using the ajax API that is included in jQuery.

something like this

$('textarea').keyup(function(){
  $.post('ajax/test.php', function(data) {
   $('#example').autocomplete(data);

   });

});

Also remember this is just the basic structure to give you an idea.

P.S. I just found this it should fill all your needs.

Bitmap
  • 12,402
  • 16
  • 64
  • 91
Breezer
  • 10,410
  • 6
  • 29
  • 50
  • Ok, sorry if this was a bad (too simple) question, im aware of this plugin, but if im not wrong it would take quite a lot of work to make it suggest only in certain words in between other words, am I wrong? – Trufa Dec 01 '10 at 22:10
  • check out the last link i posted – Breezer Dec 01 '10 at 22:26
  • Thanks Breezer! I am taking good look to the link right now (could not get you code suggestion to work yet), you've been of much help! – Trufa Dec 01 '10 at 22:35
  • This doesn't seem to have the functionality Akinator was seeking. FWIW, I ended up posting a duplicate question: http://stackoverflow.com/questions/4617557/is-there-a-jquery-autocomplete-plugin-that-can-do-completes-like-facebook-and-qu – Kiran Jonnalagadda Jan 06 '11 at 17:33
0

If you reference jQueryUI (same website as jQuery) you can use the following for auto complete: http://jqueryui.com/demos/autocomplete/

It's a simple implementation as well :)

Hope that helps!

Damien-Wright
  • 7,296
  • 4
  • 27
  • 23
  • Thank you I was trying to get a plugin that could do this in every word no matter when in the textarea, I'll give it a try to modify this one. – Trufa Dec 01 '10 at 22:22
0

This might look like a hack, but you can try imitating to the user that he is typing in the textarea, whereas he would actually be typing in the textinput which is at the position for the next word in a textarea.Once the user selects a suggestion from autocomplete or hits enter or space inside this overlaid textinput, you can remove the text-input with the current word inside the textinput appended to the textarea.

For an autocomplete in text-input you can use on plugin from the plethora of plugins available for jquery.

Neeraj
  • 8,408
  • 8
  • 41
  • 69
0

you can try gcomplete uses the google api for autocomplete anything, with a little modification to the source code, you can change the behavior about the tag input[text].

i made changes for the plugin and autocomplete the last word, you can test in github.com/rkmax/gcomplete.

I'm working on: - Autocomplete the current word. - Determine the number of lines (visual) and Textarea the current cursor position to display the list of words right next to the cursor, thanks to SimpleCoder

Community
  • 1
  • 1
rkmax
  • 17,633
  • 23
  • 91
  • 176
  • I don't believe it is going to work. The example you suggested autocompletes on the entire input without considering the cursor position. Changing the input to text area will not accomplish anything. We are looking for something like this http://bloggerindraft.blogspot.com – Vlad Oct 24 '11 at 04:46
  • i'll try to change for work in a textarea :) – rkmax Oct 24 '11 at 14:36