Help coderanch get a
new server
by contributing to the fundraiser
  • 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic