• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Wierd problem with pull down menu in Javascript

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a pull down to list countries on my form. When the user selects a country, it refreshes the page by calling the backend (Java) code (This is primarily done to update a bean). When the page returns the focus on the country field is lost. In order to fix this, I placed a <a name> tag in the html right before the country tag and call the javascript function below:

function setCountryFocus(){
document.forms[0].addrCountryCode.focus();
}

Problem: If I keep hitting the countries starting with "F", sometimes the focus goes to the BROWER's FILE->NEW. If it starts with "V" it goes to BROWSER's ->VIEW.

Can someone help me with this. Need to fix this bug asap.

Thanks!!

Problem:
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want to maintain the position on the page.

try this:


Eric
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Deepa, if nothing on the page changes, and the reload is simply to update a bean on the server, why reload the page at all? You can send a request to the server through either an XMLHttpRequest object or a simple hidden iframe. Then you don't need to worry about the focus.

-Yuriy
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic