<link href="../images/skin.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #EEF2FB;
}
.STYLE1 {color: #000000}
-->
</style>
<script language="javascript"> 
var hour=0 
var minute=10 
var second=0 
function clockShow(){ 
second=second-1; 
if (second<0) 

second=59; 
minute=minute-1; 

if (minute<0) 

minute=59; 
hour=hour-1; 

if (second==1) 

return true;
//document.form1.submit();
//window.location.href="./questions_answer.php";  

document.myform.myclock.value=hour+":"+minute+":"+second; 
var myTime = setTimeout("clockShow()",1000); } 
</script> 
<title>医学临床随访系统</title><body onLoad="clockShow()">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="../images/mail_leftbg.gif"><img src="../images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="../images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31">
          <div class="titlebt">在线考试</div>
        </td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="../images/mail_rightbg.gif"><img src="../images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="../images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="2" valign="top">&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
<form NAME="myform"> 
      <tr>
        <td colspan="2" valign="top"><span class="left_txt2">当前位置</span>:<span class="left_txt3">在线考试<b>(<?php if($_SESSION['type']==1){ echo "全科医生";}if($_SESSION['type']==2){ echo "护士";}if($_SESSION['type']==3){ echo "防保人员";}if($_SESSION['type']==4){ echo "中医";}if($_SESSION['type']==5){ echo "医技人员";}if($_SESSION['type']==6){ echo "口腔";}?>)</b></span><INPUT type="text" name="myclock" > </td></form> 

        <td width="3%">&nbsp;</td>
        </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td colspan="2" valign="top"><!--JavaScript部分-->
              <!--HTML部分
              <TABLE width=72% border=0 cellPadding=0 cellSpacing=0 id=secTable>
                <TBODY>
                  <TR align=middle height=20>
                    <TD align="center" class=sec1><a href="member_admin.php">基本资料</a></TD>
                    <TD align="center" class=sec1><a href="family_list.php">扩展资料</a></TD>
                    <TD align="center" class=sec1><a href="check_list.php">检查记录</a></TD>
                    <TD align="center" class=sec1><a href="disease_list.php">病案管理</a></TD>
                  </TR>
                </TBODY>
              </TABLE>-->
          <TABLE class=main_tab id=mainTable cellspacing=0
cellpadding=0 width=100% border=0>
                <!--关于TBODY标记-->

                <TBODY style="DISPLAY: block">
                  <TR>
                    <TD valign=top align=middle><TABLE width=98% height="133" border=0 align="center" cellpadding=0 cellspacing=0>
                        <TBODY>
                          <TR>
                            <TD height="5" colspan="3"></TD>
                          </TR>
     <TR>
                            <TD width="10%" height="28" background="../images/news-title-bg.gif">&nbsp;</TD>
                            <TD width="84%" height="28" background="../images/news-title-bg.gif" class="left_txt"><form name="form1" method="POST" action="questions.php">
                                
           <?php
if(!empty($answerList)){
$i=1;

foreach($answerList as $buf){

$_SESSION[$i]=$buf['answer'];
?>  
        <tr>
          <td width="80" height="25" align="center"><b>第<?php echo $i?>题:</b></td>
          <td align="left"><?php echo $buf['questions']; ?></td>
  <td align="left"></td>  
        </tr>
<tr>
          <td width="60" height="25" align="center"></td>
          <td align="left"><?php 
if(!empty($buf['hda'])) echo "A".":".$buf['hda'].";";
if(!empty($buf['hdb'])) echo "B".":".$buf['hdb'].";";
if(!empty($buf['hdc'])) echo "C".":".$buf['hdc'].";";
if(!empty($buf['hdd'])) echo "D".":".$buf['hdd'].";";
if(!empty($buf['hde'])) echo "E".":".$buf['hde'].";";?>
  </td>
        </tr>
<tr>
          <td width="60" height="25" align="center"></td>
          <td align="left">
<input onFocus=this.blur() type='radio' name='<?php echo $i?>' value="A">A
<input  onFocus=this.blur() type='radio' name='<?php echo $i?>' value="B">B  
<input  onFocus=this.blur() type='radio' name='<?php echo $i?>' value="C">C
<input  onFocus=this.blur() type='radio' name='<?php echo $i?>' value="D">D
<input  onFocus=this.blur() type='radio' name='<?php echo $i?>' value="E">E   </td>
        </tr>
 

  <?php



  $i++;
   }
  if($_POST["submit1"]=="提交"){
 $_SESSION['answer']=0;
 if($_POST['1']==$_SESSION[1])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['2']==$_SESSION[2])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['3']==$_SESSION[3])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['4']==$_SESSION[4])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['5']==$_SESSION[5])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['6']==$_SESSION[6])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['7']==$_SESSION[7])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['8']==$_SESSION[8])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['9']==$_SESSION[9])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['10']==$_SESSION[10])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['11']==$_SESSION[11])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['12']==$_SESSION[12])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['13']==$_SESSION[13])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['14']==$_SESSION[14])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['15']==$_SESSION[15])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['16']==$_SESSION[16])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['17']==$_SESSION[17])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['18']==$_SESSION[18])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['19']==$_SESSION[19])$_SESSION['answer']=$_SESSION['answer']+1;
 if($_POST['20']==$_SESSION[20])$_SESSION['answer']=$_SESSION['answer']+1;
 
$time=date("Y-m-d H:i:s",time());
$com_test->reset(); 
$kaoshifen=$_SESSION['answer']*5;
$sql="INSERT INTO `text_hossystem`.`com_test` (
`id` ,
usename,
`name` ,
`lianxifen` ,
`kaoshifen` ,
`time` 
)
VALUES (
NULL , '".$_SESSION['name']."','".$_SESSION['s_name']."', '', '".$kaoshifen."', '".$time."'
)
";
$insert = $com_test->_execute($sql);
AlertMsg("提交答案!");
GotoWeb("./questions_answer.php");
//die();
}
}
  ?>
 
<tr>
          <td width="60" height="25" align="center"></td>
          <td align="left"><input type="submit" name="submit1" id="button" value="提交"></td>
        </tr> 
                            </form>                               </TD>
                           
                          </TR>
                          
                          <TR>
                            <TD bgcolor="#FAFBFC">&nbsp;</TD>
                            <TD colspan="2" bgcolor="#FAFBFC"><table width="99%" border="1" cellpadding="3" cellspacing="0" bordercolor="#E2E7ED" style="border-collapse:collapse">
                            

                            </table>                            </TD>
                          </TR>
                          <TR>
                            <TD colspan="3" align="center" class="left_txt2">&nbsp;</TD>
                          </TR>
                          <TR>
                            <TD height="5" colspan="3"></TD>
                          </TR>
                        </TBODY>
                    </TABLE>
                    </TD>
                  </TR>
                </TBODY>
               
                
            </TABLE>
</td>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td height="40" colspan="3"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
          <tr>
            <td></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td width="17%">&nbsp;</td>
        <td width="80%" class="left_txt"><img src="../images/icon-mail2.gif" width="16" height="11"> 客户服务邮箱:[email protected]<br>
              <img src="../images/icon-phone.gif" width="17" height="14"> 官方网站:http://www.mbyxw.com</td>
        <td>&nbsp;</td>
        </tr>
    </table></td>
    <td background="../images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="../images/mail_leftbg.gif"><img src="../images/buttom_left2.gif" width="17" height="17" /></td>
    <td background="../images/buttom_bgs.gif"><img src="../images/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="../images/mail_rightbg.gif"><img src="../images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</body>
考试时间为10分钟
时间到强行提交        我这个程序可以做到这一点,但是强行提交没有把用户选的答案提交上去,要怎么做
急等

解决方案 »

  1.   

    <?phprequire_once '../module/prepend.inc';
    //require_once '../module/functions.inc';
    require_once '../module/DataObject.inc';
    require_once '../module/PhpTemplate.php';
    require_once '../module/t_questions.inc';
    require_once '../module/com_test.inc';
    //require_once '../module/page_class.inc';
    @session_start(); 
    //echo $_SESSION['time_in'];
    $com_test=new com_test();
    $t_questions = new t_questions();
    if($_SESSION['type']==1){//全科医生
    $sql="SELECT * FROM `t_questions` where `type`=5 or `type`=4 or type=6  ORDER BY rand( ) LIMIT 20";
    $answerList=$t_questions->_execute($sql);
    }
    if($_SESSION['type']==2){//护士
    $sql="SELECT * FROM `t_questions` where `type`=2 or `type`=4 or type=6  ORDER BY rand( ) LIMIT 20";
    $answerList=$t_questions->_execute($sql);
    }
    if($_SESSION['type']==3){//防保人员
    $sql="SELECT * FROM `t_questions` where `type`=7 or `type`=4 or type=6  ORDER BY rand( ) LIMIT 20";
    $answerList=$t_questions->_execute($sql);
    }
    if($_SESSION['type']==4){//中医
    $sql="SELECT * FROM `t_questions` where `type`=8 or `type`=1 or type=6  ORDER BY rand( ) LIMIT 20";
    $answerList=$t_questions->_execute($sql);
    }
    if($_SESSION['type']==5){//医技人员
    $sql="SELECT * FROM `t_questions` where `type`=3 or `type`=6 ORDER BY rand( ) LIMIT 20";
    $answerList=$t_questions->_execute($sql);
    }
    if($_SESSION['type']==6){//口腔
    $sql="SELECT * FROM `t_questions` where `type`=3 or `type`=6  ORDER BY rand( ) LIMIT 20";
    $answerList=$t_questions->_execute($sql);
    }
     
    $_SESSION['answer']=0;//答题对的道数?>
    这是PHP语句
      

  2.   

    时间到了用document.all.form1.submit会把用户答案提交的。下面的js代码,用了服务器时间判定用户考试时间的。
    function GetRTime(){  
    var nMS = <?=$data['lefttime']?>-runtimes;    
    var nM=Math.floor(nMS/(60)) % 60;
    if(nM>0){
    document.getElementById("remaintime").innerHTML=nM+'分钟';  
    }else{
    var nS=nMS % 60;     
    document.getElementById("remaintime").innerHTML=nS+'秒';
    }     
     
    if(nMS<0)     
    {     
    document.all.form1.submit();
    }     
    runtimes++;      
    setTimeout("GetRTime()",1000);     
    }
      

  3.   

    我用document.all.form1.submit判断时间到提交
    但是不执行if($_POST["submit1"]=="提交"){
    $_SESSION['answer']=0;
    if($_POST['1']==$_SESSION[1])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['2']==$_SESSION[2])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['3']==$_SESSION[3])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['4']==$_SESSION[4])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['5']==$_SESSION[5])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['6']==$_SESSION[6])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['7']==$_SESSION[7])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['8']==$_SESSION[8])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['9']==$_SESSION[9])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['10']==$_SESSION[10])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['11']==$_SESSION[11])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['12']==$_SESSION[12])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['13']==$_SESSION[13])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['14']==$_SESSION[14])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['15']==$_SESSION[15])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['16']==$_SESSION[16])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['17']==$_SESSION[17])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['18']==$_SESSION[18])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['19']==$_SESSION[19])$_SESSION['answer']=$_SESSION['answer']+1;
    if($_POST['20']==$_SESSION[20])$_SESSION['answer']=$_SESSION['answer']+1;
      
    $time=date("Y-m-d H:i:s",time());
    $com_test->reset();  
    $kaoshifen=$_SESSION['answer']*5;
    $sql="INSERT INTO `text_hossystem`.`com_test` (
    `id` ,
    usename,
    `name` ,
    `lianxifen` ,
    `kaoshifen` ,
    `time`  
    )
    VALUES (
    NULL , '".$_SESSION['name']."','".$_SESSION['s_name']."', '', '".$kaoshifen."', '".$time."'
    )
    ";
    $insert = $com_test->_execute($sql);
    AlertMsg("提交答案!");
    GotoWeb("./questions_answer.php");
    //die();
    }
    这段代码,等于答案没有提交上去啊