Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

onfocus in AJAX

Posted on 2009-05-18
7
Medium Priority
?
533 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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, …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

664 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