Tuesday, December 4, 2012

php – The short script doesn't work at Chrome but work at Firefox.

This is a js script checkbox to select all dates. It works at Firefox but not at 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);
?>


This is actually a php that run by a JQuery AJAX html page. When submit button is enter, a list of dates(Checkbox) and a \”select all\” checkbox is shown. Firefox definitely can work but not at Chrome.






Rating: 3 out of 5 based on 3 ratings



The post php – The short script doesn't work at Chrome but work at Firefox. appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/php-the-short-script-doesnt-work-at-chrome-but-work-at-firefox.html

No comments:

Post a Comment