Solved

onfocus in AJAX

Posted on 2009-05-18
7
516 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now