0
兩個問題:填寫日期範圍內的日期在日期排
- 當我點擊「開始」,如何填寫日期行的日期範圍內的所有日期的兩個文本框
- 如何保持文本所有IN和OUT行
當我點擊 '提交',保存到數據庫中進行文本絕:
<?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;
}
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>
歡迎來到Stack Overflow! SO並不意味着成爲「爲我編寫代碼」的網站 - 如果您正在尋找這個網站,您應該聘請專家爲您做。如果您在處理此問題時遇到*特定技術問題,請隨時編輯相應的問題。 – 2012-02-24 09:30:33