# Scriptaculous - auto complete textbox with a drop down

**URL:** <https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717>\
**Category:** Rails\
**Created:** [May 26, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717 "2006-05-26T14:45:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [May 26, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717/1 "2006-05-26T14:45:11Z")

</div>

Hi,

I’m using scriptaculous to provide an auto complete textbox - and it  
works perfectly - but I was wondering if there was anyway to let users  
navigate the choices using the keyboard i.e the curor keys as opposed to  
having to use the mouse? Apart from that it’s perfect! 🙂

Cheers,

Pete

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [May 26, 2006, 3:01pm UTC](https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717/2 "2006-05-26T15:01:16Z")

</div>

On Friday, May 26, 2006, at 2:45 PM, Pete wrote:

> Pete
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

I have been using the auto\_complete fields and I think they already do.

\_Kevin

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [May 26, 2006, 3:17pm UTC](https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717/3 "2006-05-26T15:17:09Z")

</div>

Kevin O. wrote:

> On Friday, May 26, 2006, at 2:45 PM, Pete wrote:
> 
> > Pete
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > * * *
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> I have been using the auto\_complete fields and I think they already do.
> 
> \_Kevin

Just tried it on my mac and linux and it works fine… maybe just my IE  
playing up? :S

Different issue now though - I want to update the rest of the form when  
the user tabs out of the autocomplete box. Normally I’d do this with  
onBlur() but not sure how to set that up if using the helper methods.  
Has anyone done this already?

Cheers,

Pete

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [May 26, 2006, 3:30pm UTC](https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717/4 "2006-05-26T15:30:05Z")

</div>

On Friday, May 26, 2006, at 3:17 PM, Pete wrote:

> > > removed\_email\_address@domain.invalid  
> > > the user tabs out of the autocomplete box. Normally I’d do this with  
> > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

How about a field observer?

\_Kevin

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [July 12, 2006, 11:02pm UTC](https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717/5 "2006-07-12T23:02:42Z")

</div>

On Wednesday, July 12, 2006, at 2:16 PM, Damon H. wrote:

> However, if the user types and the correct item is highlighted in the auto  
> :with =\> “‘supplier=’+$F(‘supplier\_company\_name’) + ‘&order\_type=’+‘T’”) +
> 
> > > > > 
> > > > 
> > > > \_Kevin  
> > > > Cheers,
> 
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

On my dev box (Firefox, OS X), the tab button tells the TFWAC to use the  
selected item as you might expect.

\_Kevin

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [July 12, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/scriptaculous-auto-complete-textbox-with-a-drop-down/61717/6 "2006-07-12T21:19:25Z")

</div>

Pete-

I am curious about this as well.  
I have several text\_field\_with\_auto\_complete fields in some forms that  
are  
heavy data entry intensive.  
The auto complete fields allow the user to start typing a name and then  
when  
chosen the address is automatically filled in for them.  
Everything works great if the user uses the moust to select the item  
from  
the auto complete list.  
However, if the user types and the correct item is highlighted in the  
auto  
complete list, they want to be able to TAB to the next field and the  
application complete the address just as if they had selected the entry  
with  
the mouse.

Here is an example of my TFWAC:

\<%= text\_field\_with\_auto\_complete :supplier, :company\_name, { :size =\>  
“45”  
}, :after\_update\_element =\> “function(element,value){” +  
remote\_function( :url =\> { :action =\> :get\_supplier\_address  
},  
:with =\> “‘supplier=’+$F(‘supplier\_company\_name’) + ‘&order\_type=’+‘T’”)  
+  
“}” %\>

Is there a way to tell the TFWAC to use the highlighted item in the auto  
complete list when the user hits the TAB key?

Any help would be appreciated on this.

Thanks,  
~d

On 26 May 2006 13:25:30 -0000, Kevin O. \<
