...

View Full Version : Strange problem with Focus()



Chikara
12-14-2006, 05:44 PM
http://www.sbts-marketplace.com/BrianNewFeature/stepbased/java.asp

I'm attempting to use javascript to jump to fieldset tags on that page. Basically, the page is part of a registration form. That page has around 250'ish check boxes. The idea is to use the select feature at the top of the page to quickly jump to a major category. The problem is that it seems to work correctly in IE7 but not FF2. If I change the fieldset tages to anchors, it works in FF2 but not IE7. I'm completely out of ideas on this one. Here is the script that I'm currently working with.


function pageJump()
{
var arr = new Object();
arr = document.testing.pagejump.selectedIndex;
alert("The selected value is : " + document.testing.pagejump[arr].value);
alert(document.testing.pagejump[arr].value);
var lll = new Object();
lll = document.testing.pagejump[arr].value;
alert(lll);
document.getElementById(lll).focus();
}

Please note the alert()'s are just to make sure that it's looking at the correct element. I'm completely out of ideas here and really appreciate any help!

Thanks!

koyama
12-14-2006, 06:31 PM
While the focus() method was mostly designed for form control elements, IE goes further and supports this method for virtually any element. Therefore IE allows focusing on the fieldset.

As you see, FF doesn't support focusing on a fieldset.

Instead, pick one of the checkboxes within the fieldset you want focus on and use the focus() method on this one.

I'm not a DOM expert... so anyone out there please correct me if I'm wrong.:)

Chikara
12-14-2006, 07:42 PM
Koyama, you are a life saver! This now works correctly. Thank you!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum