Wednesday, June 19, 2013

Timer

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tim.aspx.cs" Inherits="tim" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<script type="text/javascript">

var count = 0;

function changeColor() {

// Call function with 500 milliseconds gap



setInterval(starttimer, 500);

}

function starttimer() {



count += 1;

var oElem = document.getElementById("divtxt");

oElem.style.color = oElem.style.color == "red" ? "blue" : "red";

document.getElementById("lbltxt").innerHTML = "Your Time Starts: " + count;



}

</script>

</head>

<body><div id="divtxt">

<label id="lbltxt"style="font:bold 24px verdana" />

</div>

<button onclick="changeColor();">Start Timer</button>

<form id="form1" runat="server">







</form>

</body>

</html>

No comments:

Post a Comment