i need to know how to auto check all the checkboxes at specified time?
my coding is not working. thanks in advance.
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<input type="button" name="CheckAll" value="Check All">
<input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.myform.list)">
<br>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
function getCurrentTime()
{
var myDate = new Date();
var mySecs = myDate.getSeconds();
var curHour = myDate.getHours();
var curMin = myDate.getMinutes();
var suffix = "AM";
var time = curHour + ":" + curMin + ":" + mySecs + " " + suffix;
document.getElementById('time').innerHTML=(time);
if(time == "6:13:00 PM") //Change this to whatever time you want
{
for (i = 0; i < document.myform.list.length; i++)
document.myform.list[i].checked = true ;
location.reload();
}
if i use onload function, all checboxes will be checked on loading of webpage. but, the condition is "all the checkboxes should checked on reloading of web page at specified time and unchecked after 30 seconds on reloads."
currently i'm working on tme function. where user input the time and the jsp file should read it and refresh the page at user entered time. now, i'm getting NaN. help. thanks in advance. here's my code
<html>
<head>
<script type="text/javascript">//<![CDATA[
function checkSessions(theElementCB, name) {
if (hasCheckedCB(theElementCB, name)) {
return true;
} else {
alert('<format:message key="js.err.select_one"/>');
return false;
}
}
function invalidateSessions(theElement) {
if (checkSessions(theElement, 'sessionIds') && window.confirm('<format:message key="js.invalidate.confirm"/>')) {
document.getElementById('sessionsFormAction').value='invalidateSessions';
return true;
} else {
return false;
}
}
function getCurrentTime()
{
var myDate = new Date();
var mySecs = myDate.getSeconds();
var curHour = myDate.getHours();
var curMin = myDate.getMinutes();
var suffix = "AM";
<% String reloadTime=request.getParameter("reloadTime"); %>
<script type="text/javascript">
function CheckAll(sessionIds,flag) {
var obj = document.getElementById(sessionIds);
var sel = obj.getElementsByTagName('input');
for (var i=0; i<sel.length; i++) {
if (sel[i].type == 'checkbox') { sel[i].checked = flag; }
}
}
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="00:10";
//alert();
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh
{
CheckAll('CBoxList',true);
var t = setTimeout('resetCBox()',5000);
}
function resetCBox() {
CheckAll('CBoxList',false);
}
Bookmarks