Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use setTimeout function

 
pravin rasal
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64713
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"didn't work" is not helpful. What did happen? Please show us the complete code and what you tried to do.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First problem is $("#text4").val(i) is being executed right away. You need to use a closure/anonymous function.

Eric


 
pravin rasal
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to display value in text field some interval
 
pravin rasal
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my problem solved
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic