Solved

onfocus in AJAX

Posted on 2009-05-18
7
526 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

622 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