wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes how to use setTimeout function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to use setTimeout function" Watch "how to use setTimeout function" New topic
Author

how to use setTimeout function

pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 63
I have following code




I want to set the value in the text field "text4" by decrementing "no" variable by some second but it didn't working please help me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

"didn't work" is not helpful. What did happen? Please show us the complete code and what you tried to do.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
First problem is $("#text4").val(i) is being executed right away. You need to use a closure/anonymous function.

Eric


pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 63
i want to display value in text field some interval
pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 63
In JavaScript I have following code:


If I have no =4000 then I want to display that number in textfield(i.e text4) but after some interval means 4000 -'500ms'-3999-'500ms'-3998-'500ms'...........to -'500ms'-0.
pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 63
my problem solved
Thanks
 
 
subject: how to use setTimeout function