Jump to content

attendance table


mdvignesh

Recommended Posts

Two question? 1. When i click 'Go' , how to fill DATE row all dates of the date range in the two text box

 

2. how to keep textbox for all IN and OUT row

 

wen i click 'submit' the in out textbox must saved to DB

 

First help for 1st qustn

 

	<?php
session_start();
if (!$_SESSION['uname']) {
header("Location:login.php");
}
?>
<html><head><title>Attendance sheet</title>
<link rel="stylesheet" href="att_style.css" type="text/css" >
<script src="datetimepicker.js"> </script>
<script type="text/javascript">

function IsNumber(strFieldValue, size, strAlert)
{
for ( var i=0; i < size; i++)
{     
if(strFieldValue.charAt(i)!="" )
{	    
if( strFieldValue.charAt(i) < "0" || strFieldValue.charAt(i) > "9")
{
if(strAlert != "")alert(strAlert)
return false;

}
}
}
return true;
}

function IsValidTime(timeStr) {
var timePat = /^(\d{1,2})\d{2})(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) 		{
alert("You must specify AM or PM.");
return false;
}
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return false;
} 
</script>
</head>
<body>
<form name="timeform" method="post" action="" >

<label for="range_start">Start range:</label> <input name="from" id="frm_date" type="text" >

<a href="javascript:NewCal('frm_date','ddmmyyyy')"><img src="cal.gif" alt="pick a date"></a>
    

<label for="range_end">End range:</label> <input name="to" id="dpk" type="text" >

<a href="javascript:NewCal('dpk','ddmmyyyy')"><img src="cal.gif" alt="pick a date"></a>
  

<input name="date_but" type="submit" value="Go">
<a style="float:right" href="logout.php">Logout</a>
<br/><br/>
<?php
if (isset($_REQUEST['date_but'])) {
$fromDate = $_REQUEST['from'];
$toDate = $_REQUEST['to'];

$dateMonthYearArr = array();
$fromDateTS = strtotime($fromDate);
$toDateTS = strtotime($toDate);

for ($currentDateTS = $fromDateTS; $currentDateTS <= $toDateTS; $currentDateTS += (60 * 60 * 24)) {

$currentDateStr = date("d-M-Y",$currentDateTS);
$dateMonthYearArr[] = $currentDateStr;

php 
}


echo "No of days: " . count($dateMonthYearArr);
?>
<table border="1" cellspacing="0" cellpadding="5" align="center">
<tr>
<th scope="row">DATE</th>
<div class="dat_row">
<td><?php print_r($dateMonthYearArr[0]); ?></td>
<td><?php echo $dateMonthYearArr[1]; ?></td>
<td><?php echo $dateMonthYearArr[2]; ?></td>
<td><?php echo $dateMonthYearArr[3]; ?></td>		
</div>

</tr>
<tr>
<th scope="row">IN</th>
<td><input name="time" type="text" ></td>
<td><input name="r2_in" type="text" ></td>
<td><input name="r2_in" type="text" ></td>
</tr>
<tr>
<th scope="row">OUT</th>
<td><input name="time" type="text"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<th scope="row">Leave</th>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table><br/><br/>
<input name="submit" type="submit" onClick="IsValidTime(document.timeform.time.value);" value="Submit">
<?php

} ?>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/257682-attendance-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.