Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 18th, 2007, 06:29 PM
Registered User
Join Date: Dec 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML anchor and JS focus not working together


I have a form in which there are 2 dropdowns for Country and State respectively (in the middle of the form). When I select a value from the Country dropdown the page refreshes and loads the State dropdown with the relevant state names. I want the page to remain in the same place where it was before refreshing the page (ie., I dont want the page to go to the top after refreshing) and also I want the focus to be on the State dropdown after refershing. For this I created a HTML anchor as below

<a name="cntrystateanchor" />
      <select class="small3 formfieldwidth2" name="countryDDList" id="countryDDList" onchange="javascript:getStates();">
    <option value="" selected >- Please Select -</option>
    <% Iterator keys= countrylist.keySet().iterator();
                                   while(keys.hasNext() ){
                                  ........... <% } %>

When the page is done with refreshing I am doing the following

document.location = "#cntrystateanchor";

My page is staying at the same place after refreshing but the focus is not getting set to the 'States' dropdown. If I remove the "document.location = "#cntrystateanchor";" the focus is getting set correctly to the 'States' dropdown but as expected the page is going to the top after refreshing (as I removed the document.location).

Can someone please help me with this.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for body element in an html not working aldwinenriquez XML 8 August 28th, 2008 05:56 AM
anchor link not working in IE6 sbkumar CSS Cascading Style Sheets 2 July 29th, 2008 11:27 AM
only do HTML/ASP when JS variable = true crmpicco Javascript How-To 1 July 19th, 2005 05:06 AM
Myasp code is not working while html give results Raz Muhammad .NET Web Services 1 March 3rd, 2004 04:21 AM
Trigger a JS function on loss of focus apd8x Javascript 1 July 14th, 2003 09:00 AM

All times are GMT -4. The time now is 11:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.