• 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

onblur

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a requirement where I need to calaculate the value of one field which depends upon the value of 5-6 other fields on the html.
I am thinking of using onblur event for all these participating fields .
Is there any better approach.

Thanks
Ajai
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it depends on what you want. In your case value will not be calculated until the field you change actually looses focus. If this is ok, you can use onblur or onchange.

Otherwise, your options are:
1. onkeyup or onkeypress (you will need to comeup with some way to handle cut/paste)
2. setInterval - recalculate the value every time interval
3. more fancy setTimeout - onfocus will initiate timeout to recalculate the value, each keypress will cancel previous timeout and start a new one.
 
Ajai
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

Assume a scenario where I have 5 fields which determine the output of 6th field.
I am done with all 5 and going to press submit imm after this.
So in this case user will not be able to see the value of 6th field.or he will see it only for a fraction of time when the key is pressed on submit button.which is not very user freindly.

I think even time out will not help in above scenario.
Am I right in understanding what you shared.

Thanks
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think a half second timeout will be ok
 
reply
    Bookmark Topic Watch Topic
  • New Topic