Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

document.forms[0].elements.focus() is not working in IE 7.0+ and FF 3.0

 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,

I am trying the following code since long time .As It prompts and runs fine in IE 6.0 but in all the upper versions it fails .As cursor moves to next textbox rather than the same .




I am using that code in my JSP as





Please help me I tried lots of things but failed !!!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do the id.focus() after the alert statement

You also probably want to use onblur

Eric
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from this problem, using document.forms[x] instead of document.formname or document.getElementById(formid) is a bad practice and receipt for trouble.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. Using names instead of ids for DOM navigation is a quaint and old-fashioned practice that should be avoided.
 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:Apart from this problem, using document.forms[x] instead of document.formname or document.getElementById(formid) is a bad practice and receipt for trouble.


Thanks For Early Reply! But I tried lots of things but failed .As all the time cursor moves to next textbox.It is working fine with IE6.0 but for latest browser it prompts but on clicking OK button it moves to next textbox without further prompting.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone said something about onblur.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
onchange is not fired on every keystroke. It is fired when focus is removed from the element and the data has changed.

Eric
 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:onchange is not fired on every keystroke. It is fired when focus is removed from the element and the data has changed.

Eric


Thanks Eric !! But It is Still not running .
I am sending my javascript code which is in js file



I am calling this function as



It is not working in IE 7.0 and FF 3.0 !!




 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any One can solve this problem ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic