HighDots Forums  

Re: Get current word being typed in a text input field

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Get current word being typed in a text input field in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dan Rumney
 
Posts: n/a

Default Re: Get current word being typed in a text input field - 06-03-2008 , 09:46 PM






On Jun 3, 9:23 pm, darius <no... (AT) here (DOT) invalid> wrote:
Quote:
Hello

I'm doing a bit of AJAX auto completion. The text field is a string of
tags separated by spaces. My problem is I need to know which is the
current word that I need to autocomplete.

When the user starts typing, I can assume it's the last word that needs
to be autocompleted: ([] is the caret)

pictures fun[]

But when she backs up to edit or insert another word

pictures anim[] funny

here I need to know I'm autocompleting 'anim'. How do I determine that?
This page http://blog.vishalon.net/Post/57.aspx talks about getting
and setting the caret location in a textarea.

Then, take the substring of the entry field from the start of the
string to the position of the caret.

Then, perform a split on the space character

Then, take the last item the the resulting array.

That's one way to do it... but what happens in the following scenario?

"pictures anim [] funny"

You need to decide what you want to happen in this case before you can
decide how to implement it


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.