Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in IE 5

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,
Can someone help me to get rid of this javascipt error.
I have one javascript function as below in one JSP application.
What i intend to do with this function is whenever user selects any of radio
button from group of radio buttons, the selected radio button should get focus. I have many HTML controls on this page besides radio buttons.
Here is the code.
function setFocus()
{
obj=document.forms["formname"].elements;
for (i=0;i<obj.length;i++){
if (obj[ i ].type=="radio" ){
if( obj[ i ].checked == true ){
obj[ i ].focus();
}
}
}
}
I m calling this function at the end of page.This works perfectly fine in IE 6.0 but it does not work in IE 5.If i try to access same in IE 5, i m getting javascript error..
"Error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept a focus."
Can anybody have any idea why this does not work in IE 5?
Thanks.
Himanshu
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you might want to try this
function setFocus()
{
objF=document.forms["formname"]
obj = objF.elements;
for (i=0;i<obj.length;i++){
if (obj[ i ].type=="radio" ){
if( obj[ i ].checked == true ){
obj[ i ].selected;
objF.focus()
}
}
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic