Solved

onfocus in AJAX

Posted on 2009-05-18
7
518 Views
Last Modified: 2013-12-12
We have a form with AJAX autosuggest facility.

What we want to do is that once we select an item in an autosuggest field, the cursor should automatically move to the next field, so as to save time of the user. Is that possible? If yes, how?  
0
Comment
Question by:designmantras
  • 2
  • 2
7 Comments
 
LVL 19

Expert Comment

by:moagrius
ID: 24413128
Yes.  Exactly how depends on the nature of the element handling the autosuggest functionality.  Just use the element.focus() method when the user accepts the suggestion, where "element" is a reference to the next element on the form you want to pass focus to.
0
 
LVL 1

Author Comment

by:designmantras
ID: 24428825
Please give me a example of AJAX autosuggest facility.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24428984
0
 
LVL 1

Author Comment

by:designmantras
ID: 24429189
What we want to do is that once we select an item in an autosuggest field, the cursor should automatically move to the next field, so as to save time of the user. Is that possible? If yes, how?  please give me a example..
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 24429321
http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleter

afterUpdateElement                   null                   
Hook for a custom function that's called following the execution of the built-in function that adds the list item text to the input field, which happens after a user has selected an entry. (The difference between updateElement and afterUpdateElement is that updateElement replaces the built-in Autocompleter function; afterUpdateElement supplements that built-in function.) The function receives two parameters, the input field specified for autocompletion, and the selected item (the <li> item selected)



new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "/url/on/server", {
  afterUpdateElement : focusNext
});
 
var idOfFieldAfterAutoComplete = "field2";
function focusNext() {
    document.getElementById(idOfFieldAfterAutoComplete).focus();
}

Open in new window

0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question