Click here to Skip to main content
15,886,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make one timer + counter program in which
i have one text box in which i will enter seconds and start timer
timer will show time in second and display seconds up to which i have enter in the label and timer will restart and again display seconds which i have enter,counter will count each time timer restart.

ex:
i have take 30 sec , my timer will show time from 1 to 30 sec and it will restart and again start will 1 to 30 sec, and counter will display how many time my time has restart means whenever timer will restart my counter count will increase..

Plz help me how to do this ????
thanks in adavance
Posted
Updated 9-Dec-11 16:21pm
v2

 
Share this answer
 
Comments
Bhavik_Patel 9-Dec-11 22:31pm    
no man i already refer this.
Refer this link:


http://www.codingforums.com/showthread.php?t=62145
 
Share this answer
 
<script language="JavaScript">
TargetDate = "12/31/2020 5:00 AM";
BackColor = "palegreen";
ForeColor = "navy";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
FinishMessage = "It is finally here!";
</script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>
 
Share this answer
 
Count Down Counter (ASP.Net, JavaScript, C#)

ASP.Net Code

While displaying a count down timer on your Web Page you need to do following things :

On the web page you need to add 7 controls.

In that one is HTML Text box which displays the count down time

<input type=”text” readonly =”true” size=”8″ id=”counter” style=”text-align:center; font-size:x-large; font-weight:bold; color:Red;” />

and rest of six are hidden fields in which three of them are HTML controls and other are ASP controls looks loke this



<input type=”hidden” size=”8″ id=”HidHours” value=”<%=HidH.Value%>“/>

<input type=”hidden” size=”8″ id=”HidMinutes” value=”<%=HidM.Value%>“/>

<input type=”hidden” size=”8″ id=”HidSeconds” value=”<%=HidS.Value%>“/>

<asp:HiddenField ID=”HidH” runat=”server” Value=”0″ />

<asp:HiddenField ID=”HidM” runat=”server” Value=”0″ />

<asp:HiddenField ID=”HidS” runat=”server” Value=”0″ />

Now you need to write the main JavaScript part which displays this count down time

<script>

var hours=document.getElementById(‘HidHours’).value;

var minutes=document.getElementById(‘HidMinutes’).value;

var seconds=document.getElementById(‘HidSeconds’).value;

function

display()

{

if (seconds<=0)

{

if ((hours==0)&&(minutes==0))

seconds=0;

else

{

seconds=60;

minutes-=1;

}

}

if (minutes<=0)

{

if ((hours<0)&&(minutes<0))

{

hours = minutes = seconds = 0;

}

else

{

if ((hours==0)&&(minutes==0))

hours=minutes=0;

if ((hours>0)&&(minutes<0))

{

minutes=59;

hours-=1;

}

}

}

if ((minutes<=-1)||(hours<=-1))

{

if (hours<=-1)

{

minutes=0;

hours+=1;

}

else

minutes-=1;

seconds=0;

minutes+=1;

}

else

if (seconds>0)

seconds-=1;

document.getElementById(‘counter’).value=hours+“:”+minutes+“:”+seconds;

setTimeout(“display()”,1000);

}

display();

</script>

C# Code

TimeSpan ts;

HidH.Value = Convert.ToString(ts.Hours);

HidM.Value = Convert.ToString(ts.Minutes);

HidS.Value = Convert.ToString(ts.Seconds);
 
Share this answer
 
Comments
priya from Madras 10-Dec-11 0:09am    
also refer this :http://www.daniweb.com/software-development/csharp/threads/303291
still not getting any satisfy answer
 
Share this answer
 
Comments
lukeer 12-Dec-11 4:54am    
That's not something to post as a solution. Improve your question instead. Give some more detail what you're trying to achieve and why given solutions don't fit your needs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900