focus() problem for radio object in IE

P

Paul Thompson

I am trying to use various javascript tools, all of which work in NN, to
work in IE.

Here's my latest annoyance.

I get a list of all objects on a page using

docContents = document.getElementsByTagName("*");
for (var i=0; i < docContents.length; i++) {
if (docContents.type == 'text' ||
docContents.type == 'textarea' ||
docContents.type == 'radio' ||
docContents.type == 'checkbox' ||
docContents.type == 'select-one' ||
docContents.type == 'select') {zmaxv++;}
}

I then select an object to switch focus to. I can use the focus()
method for text objects, select list objects, but not radio buttons.
Why not?

To switch focus, I say

docContents[dCitems[curpos]].focus();

where dCitems contains the position in the array. This works fine, BTW,
for everything but radio objects.

I also tried

document.getElementByName('_sex')[0].focus();

here again I get the problem of the focus not being allowed for this
radio object.


Thoughts? Suggestions?
 
S

slogeek

Your radio buttons are probably double arrays. I had a similar
experience and was not able to access most of the properties of a
radio button until I specified both elements in the double array.
This explains why the first snippet may have trouble, but

document.getElementByName('_sex')[0].focus();

seems like it should work. Have you tried making sure you are
referring to a valid radio button e.g.

alert(document.getElementByName('_sex').length)

length is the one property of a radio button I could access from a
single array.

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top