IT Community - Software Programming, Web Development and Technical Support

count the time in seconds that a checkbox is really checked

This is a discussion on count the time in seconds that a checkbox is really checked within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all.... Can anyone help me how can i count the time in seconds that a checkbox is really checked. ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 02-13-2008, 09:11 PM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default count the time in seconds that a checkbox is really checked

Hi all....


Can anyone help me how can i count the time in seconds that a checkbox is really checked.

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 02-13-2008, 09:16 PM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 235
Pvinothkumar is on a distinguished road
Default Re: count the time in seconds that a checkbox is really checked

Hi all...


<form name="myForm">
<input name="myCheckBox" type="checkbox">
<input name="totalTime" type="text">
</form>

<script language="JavaScript">
function timer() {
if (document.myForm.myCheckBox.checked != isitchecked) {
// checkbox clicked
isitchecked = document.myForm.myCheckBox.checked;
now = new Date()
if (isitchecked)
starttime = now.getTime(); // now checked so reset starttime
else
document.myForm.totalTime.value = 0; // no longer checked so reset
}
else {
// not clicked since last check
if (isitchecked) {
// still checked
now = new Date();
totaltime = now.getTime() - starttime; // totaltime in milliseconds that checkbox has been checked.
document.myForm.totalTime.value = totaltime/1000/60; // time in minutes
}
}
setTimeout('timer()',100);
}

var totaltime = 0;

document.myForm.totalTime.value = totaltime;

var isitchecked = document.myForm.myCheckBox.checked;

if (isitchecked) {
now = new Date()
starttime = now.getTime(); // if intial stae is check then set starttime
}

timer(); // start constant monitoring of checkbox
</script>

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count down in seconds from the current time to the year 2000 itbarota HTML, CSS and Javascript Coding Techniques 1 03-07-2008 01:56 AM
Count down from 15 seconds and then display an alert message itbarota HTML, CSS and Javascript Coding Techniques 2 02-29-2008 12:15 AM
When should u use a checked & unchecked exception in java? H2o Java Programming 1 07-24-2007 02:47 AM
How to postback the checkbox value in treeview when each time it is checked ? bluesky ASP and ASP.NET Programming 0 07-15-2007 11:24 PM
Checked and UnChecked Exception sivakumar Java Programming 1 07-12-2007 03:01 AM


All times are GMT -7. The time now is 11:04 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0