By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

focus() problem for radio object in IE

P: n/a
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[i].type == 'text' ||
docContents[i].type == 'textarea' ||
docContents[i].type == 'radio' ||
docContents[i].type == 'checkbox' ||
docContents[i].type == 'select-one' ||
docContents[i].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?

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
problem fixed

Paul Thompson wrote:
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[i].type == 'text' ||
docContents[i].type == 'textarea' ||
docContents[i].type == 'radio' ||
docContents[i].type == 'checkbox' ||
docContents[i].type == 'select-one' ||
docContents[i].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?


Jul 20 '05 #2

P: n/a
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

Paul Thompson <pa**@wubios.wustl.edu> wrote in message news:<3F**************@wubios.wustl.edu>...
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[i].type == 'text' ||
docContents[i].type == 'textarea' ||
docContents[i].type == 'radio' ||
docContents[i].type == 'checkbox' ||
docContents[i].type == 'select-one' ||
docContents[i].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?

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.