HighDots Forums  

focus() problem for radio object in IE

Javascript JavaScript language (comp.lang.javascript)


Discuss focus() problem for radio object in IE in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Paul Thompson
 
Posts: n/a

Default focus() problem for radio object in IE - 12-02-2003 , 04:08 PM






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?


Reply With Quote
  #2  
Old   
Paul Thompson
 
Posts: n/a

Default Re: focus() problem for radio object in IE - 12-04-2003 , 10:57 AM






problem fixed

Paul Thompson wrote:
Quote:
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?



Reply With Quote
  #3  
Old   
slogeek
 
Posts: n/a

Default Re: focus() problem for radio object in IE - 12-04-2003 , 12:25 PM



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 <paul (AT) wubios (DOT) wustl.edu> wrote

Quote:
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?

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.