これは、すべての日付を選択するための js スクリプト チェックボックスです。Firefox では機能しますが、Chrome では機能しません。
<script type="text/javascript" charset="utf-8">
function toggle(source) {
checkboxes = document.getElementsByName('check_time[]');
for each(var checkbox in checkboxes)
checkbox.checked = source.checked;
}
</script>
<?php
session_start();
include ("include/dbconnect.php");
$timestamp = mysql_real_escape_string(strtotime($_POST['date']));
$doc_username = $_SESSION['username'];
$date = @ strip_tags (date("Y-m-d",$timestamp));
$timezone ="Asia/Kuala_Lumpur";
if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
$todaydate = date("Y-m-d");
if($date == '')
{
echo "<i>Please select a date</i>";
}else if ($date < $todaydate)
{
echo "<i>* You are not allowed to choose date before $todaydate</i>";
}else
{
$inc = 1800;
$start = (strtotime('0830')); // 9 AM
$end = (strtotime('1630')); // 5 PM
echo "<b>*Pick if the time is not available</b><br> <br>";
echo "<form action='doc_confirmtime.php' method='POST'>";
echo "<input type='checkbox' onClick='toggle(this)' />Select All<br/>";
for( $i = $start; $i <= $end; $i += $inc )
{
$timeslot = date( 'G:i:s ', $i + $inc );// to the standart format
$query = mysql_query("SELECT * from appointment Limit 1");
while($row = mysql_fetch_array($query))
{
$date2 = $row['date'];
$time = $row['time'];
$query2 = mysql_query("SELECT doc_username, date, time, status from appointment WHERE (doc_username = '$doc_username' AND date = '$date' AND time = '$timeslot') AND (status = '0' OR status = '1' OR status = '2' OR status is NULL)");
$result = mysql_fetch_array($query2,0);
if ($result > 0)
{
echo "<font size='+1' face='Tahoma, Geneva, sans-serif'><input type='checkbox' name='check_time[]' value='$timeslot' checked = 'checked' DISABLED><b>$timeslot</b></font><br>";
}else
{
echo "<font face='Arial, Helvetica, sans-serif'><input type='checkbox' name='check_time[]' value='$timeslot'>$timeslot</font><br>";
}
}
}
echo "<i>*Highlighted Time has chosen by you or your patient</i>";
echo "<br><br>";
echo "<input type='submit' name='submit' value='Submit' style='width:60px; height=30px' />";
echo "<input type='hidden' name='Date' value='$date' >";
echo "</form>";
}
mysql_close($connect);
?>
これは実際には、JQuery AJAX html ページによって実行される php です。送信ボタンを押すと、日付の一覧(チェックボックス)と「すべて選択」チェックボックスが表示されます。Firefox は確実に動作しますが、Chrome では動作しません。