• 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

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

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !!!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do the id.focus() after the alert statement

You also probably want to use onblur

Eric
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Someone said something about onblur.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any One can solve this problem ??
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic