|
|
|
โค้ดนับเวลาถอยหลัง ถ้าจะทำให้เวลากดrefreshแล้ว มันไม่ต้องเริ่มนับเวลาใหม่ยังไงคับ แล้วพอเวลาหมดมันจะไม่ส่งค่าไปอ่ะคับ |
|
|
|
|
|
|
|
ผมลองค้นหาจากกระทู้เก่า แล้วทำตามดูแล้ว แต่เวลารีเฟชแล้วมันจะเริ่มนับเวลาใหม่อ่ะคับ
แล้วก็พอเวลามันถอยหลังจนหมด มันเหมือนจะไม่ส่งค่าhiddenไปอ่ะคับ ต้องไปแก้ตรงไหนบ้างคับ ขอคำแนะนำทีคับ
random.php
<?
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="5; url=random_check.php;">
<?
if(!isset($_SESSION['username']))
{
echo"<script>alert('คุณยังไม่ได้เข้าสู่ระบบ!!');window.location='index.php';</script>";
exit();
}
?>
<script language="javascript">
window.history.forward(-1);
</script>
<body>
<body onLoad="begintimer()">
<script language="">
var limit="0:10"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function begintimer(){
if (!document.images)
return
if (parselimit==1){
// เหตุการณ์ที่ต้องการให้เกิดขึ้น
window.location='random_check.php';// ถ้าต้องการให้กระโดดไปยัง Page อื่น
frmTest.submit();}
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime="เวลาที่เหลือ <font color=red> "+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที "
else
if(cursec==0)
{
alert('หมดเวลาแล้วจ้า');
}
else
{
curtime="เวลาที่เหลือ <font color=red>"+cursec+" </font>วินาที "
}
document.getElementById('dplay').innerHTML = curtime;
setTimeout("begintimer()",1000)
}
}
//-->
</script>
<div id=dplay ></div>
<FORM METHOD="POST" name="frmTest" ACTION="random_check.php" enctype="multipart/form-data">
<?php
$number=1;
$test_subject=$_GET[test_subject];
include "connect.php";
$sql="SELECT tb_test.*
FROM tb_test,subject
where tb_test.sj_id=subject.sj_id and tb_test.sj_id='$test_subject'
ORDER BY RAND() LIMIT 0,20";
$result=mysql_db_query("$dbname",$sql);
while ($r=mysql_fetch_array($result)) {
$id=$r[id];
$question=$r[question];
$picture=$r[picture];
$choice1=$r[choice1];
$choice2=$r[choice2];
$choice3=$r[choice3];
$choice4=$r[choice4];
if($picture!=""){
echo "<B>ข้อ $number. $question </B><BR>
<img src='admin/images/$picture'><BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='1'> $choice1 <BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='2'> $choice2 <BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='3'> $choice3 <BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='4'> $choice4
<INPUT TYPE='hidden' NAME='total_question[]' VALUE='$id'>
<INPUT TYPE='hidden' NAME='test_subject' VALUE='$test_subject'>
<HR> ";
$number++;
}
else{
echo "<B>ข้อ $number. $question </B><BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='1'> $choice1 <BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='2'> $choice2 <BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='3'> $choice3 <BR>
<INPUT TYPE='radio' NAME='select_$id' VALUE='4'> $choice4
<INPUT TYPE='hidden' NAME='total_question[]' VALUE='$id'>
<INPUT TYPE='hidden' NAME='test_subject' VALUE='$test_subject'>
<HR> ";
$number++;
}
}
?>
<INPUT TYPE="submit" VALUE="ส่งคำตอบ">
</FORM>
</body>
random_check
<?
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
if(!isset($_SESSION['username']))
{
echo"<script>alert('คุณยังไม่ได้เข้าสู่ระบบ!!');window.location='index.php';</script>";
exit();
}
?>
<?
$total_question=$_POST['total_question'];
$test_subject=$_POST['test_subject'];
$correct=0;
$total=count($total_question);
include "connect.php";
$sql="select id,answer from tb_test order by id";
$result=mysql_db_query("$dbname",$sql);
while ($r=mysql_fetch_array($result)) {
$id=$r[id];
$answer=$r[answer];
if (in_array($id,$total_question)) {
$select = $_POST["select_".$id];
if ($select==$answer) {
$correct++;
}
}
}
$username=$_SESSION['username'];
$today = date("Y-m-d");
$sql2 = "select sj_id from tb_score where mem_user ='$username' and sj_id='$test_subject' ";
$rs = mysql_query($sql2)or die('ประมวผลไม่ได้ '.$sql2.'<br>เนื่องจาก: ' . mysql_error());
$row = mysql_fetch_array($rs);
if($row[sj_id]!=$test_subject){
$sql3="insert into tb_score values('','$username','$test_subject','$correct','$today')";
}else{
echo"<script>alert('คุณสอบวิชานี้ไปแล้วครับ!!');window.location='index.php';</script>";
}
mysql_query($sql3)or die('ประมวผลไม่ได้ '.$sql3.'<br>เนื่องจาก: ' . mysql_error());
echo "<h2>ถูกต้องทั้งหมด $correct ข้อ <BR>ข้อสอบทั้งหมด $total ข้อ</h2>";
?>
Tag : JavaScript
|
|
|
|
|
|
Date :
2010-12-22 02:56:22 |
By :
หมูบิน |
View :
1916 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
session_start();
session_destroy();
$booking = $_REQUEST['booking_name'];
$cheap = $_REQUEST['cheap'];
$chic = $_REQUEST['chic'];
$boutique = $_REQUEST['boutique'];
?>
<script language="JavaScript" type="text/javascript">
function checkChang(){
var t = setTimeout("document.booking.submit();",0); //2 seconds measured in miliseconds
}
</script>
<div>BOOKING PROGRAM</div>
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr>
<td height="35" colspan="2">Reservation information</td>
</tr>
<tr>
<td width="27%">Program Name:</td>
<td width="73%"><?php echo $booking ;?></td>
</tr>
<tr>
<td height="30">Price:</td>
<td height="30">6,340 THB
<?php
if($cheap==""){
echo "";
}else{
//$total1 = 6340+6304;
//$total2 = 6340+4250;
//$total3 = 6340+6840;
if($cheap=="5 Days at Bangkok 6,340 THB"){
echo $cheap;
echo " ";
//echo "<b>Totel</b>"." ".$total1." "."THB";
}
else if($cheap=="5 Days at Chaing Mai 4,250 THB"){
echo $cheap;
echo " ";
//echo "<b>Totel</b>"." ".$total2." "."THB";
}else{
echo $cheap;
echo " ";
//echo "<b>Totel</b>"." ".$total3." "."THB";
}
}
if($chic==""){
echo "";
}else{
echo $chic;
echo " ";
//echo "<b>Totel</b>"." ".$total2." "."THB";
}
if($boutique==""){
echo "";
}else{
echo $boutique;
echo " ";
//echo "<b>Totel</b>"." ".$total3." "."THB";
}
?>
</td>
</tr>
<!--
<tr>
<td height="30">Arrival date:</td>
<td height="30"><script>DateInput('sdate', true, 'yyyy-mm-dd')</script></td>
</tr>
<tr>
<td height="30" valign="top">Number of people:</td>
<td height="30">
<select name="select" id="select">
<option value="---- Selection ---">---- Selection ---</option>
</select>
Adult (s)<br />
<select name="select2" id="select2">
<option value="---- Selection ---">---- Selection ---</option>
</select>
Child (3-12 years)<br />
<select name="select3" id="select3">
<option value="---- Selection ---">---- Selection ---</option>
</select>
Infant</td>
</tr>
-->
<form id="booking" name="booking" action="booking_program.php?booking_name=<?= $booking ?>" method="post">
<tr>
<td height="30" valign="top">Excursion additional:</td>
<td height="30">
1.Cheap
<select name="cheap" id="cheap" onchange ="checkChang()">
<option value="" name="---- Selection ---">---- Selection ---</option>
<option value="| [5 Days at Bangkok] Price 6,340 THB." name="5 Days at Bangkok">5 Days at Bangkok 6,340 THB </option>
<option value="| [5 Days at Chaing Mai] Price 4,250 THB." name=" 5 Days at Chaing Mai"> 5 Days at Chaing Mai 4,250 THB</option>
<option value="| [5 Days at Phuket] Price 6,840 THB." name="5 Days at Phuket ">5 Days at Phuket 6,840 THB </option>
</select>
<br />
2.Chic
<select name="chic" id="chic" onchange ="checkChang()">
<option value="" name="---- Selection ---">---- Selection ---</option>
<option value="| [5 Days at Bangkok] Price 13,475 THB " name="5 Days at Bangkok">5 Days at Bangkok 13,475 THB </option>
<option value="| [5 Days at Chaing Mai] Price 12,375 THB" name="5 Days at Chaing Mai"> 5 Days at Chaing Mai 12,375 THB </option>
<option value="| [5 Days at Phuket] Price 16,090 THB " name="5 Days at Phuket">5 Days at Phuket 16,090 THB </option>
</select>
<br />
3.Boutique
<select name="boutique" id="boutique" onchange ="checkChang()">
<option value="" name="---- Selection ---">---- Selection ---</option>
<option value="| [5 Days at Bangkok] Price 18,770 THB " name="5 Days at Bangkok">5 Days at Bangkok 18,770 THB </option>
<option value="| [5 Days at Chaing Mai] Price 15,920 THB" name="5 Days at Chaing Mai"> 5 Days at Chaing Mai 15,920 THB </option>
<option value="| [5 Days at Phuket] Price 21,090 THB" name="5 Days at Phuket">5 Days at Phuket 21,090 THB </option>
</select>
<br />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" value="OK" name="value(Submit)" onclick="javascript:return Login_Form_Validator(document.parameter)" onmouseover="this.style.cursor='hand'"/>
</td>
</tr>
<tr>
<td>Total Price :</td>
<td>
<?php
$total = 6340;
$total1 = 4250;
$total2 = 6840;
$total_1 = $total+$total;
$total_2 = $total+$total1;
$total_3 = $total+$total2;
if($cheap==""){
echo number_format($total, 2 , '.' , ',' )." "."THB.";
}else{
echo number_format($total_1, 2 , '.' , ',' )." "."THB.";
}
?>
</td>
</tr>
</form>
</table>
|
|
|
|
|
Date :
2012-11-21 16:35:49 |
By :
attaporn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|