gpt4 book ai didi

java - 如何设置定时器自动提交

转载 作者:行者123 更新时间:2023-12-02 04:59:55 25 4
gpt4 key购买 nike

请帮助我解决我的问题,我无法在提交后自动提交我的测验,计时器将刷新。

<?php

//get the value of all the needed information
$student_sql = mysql_query("SELECT * FROM students WHERE student_id='$_SESSION[student]' LIMIT 1");
while($s = mysql_fetch_array($student_sql)) {
$fname = $s["first_name"];
$lname = $s["last_name"];
$_SESSION['first_name'] = $fname;

}
$question_sql = mysql_query("SELECT * FROM questionnaire WHERE questionnaire_id='$_SESSION[questionnaire]'");
while($q = mysql_fetch_array($question_sql)) {
$total = $q["questionnaire_total"];
}
$cat_sql = mysql_query("SELECT * FROM question WHERE category_id='$_SESSION[question]'");
while($y = mysql_fetch_array($cat_sql)) {
$cate = $y["category_id"];
}

define("NL","<br>\n");
$status = "true";
if(!isset($_POST["set"])) {
$_SESSION["i"] = 0;
$_SESSION["correct"] = 0;
$_SESSION["incorrect"] = 0;
}
if(isset($_POST["set"])) {
if($_POST["submit"]) {
if($_SESSION["i"] == $total) {
unset($_SESSION["i"]);
#unset($_SESSION["correct"]);
#unset($_SESSION["incorrect"]);
#$_SESSION["correct"] = 0;
#$_SESSION["incorrect"] = 0;
$_SESSION["i"] = 0;
header("location: evaluate.php");
}
if(empty($_POST["choice"])) {
$_SESSION["incorrect"] = $_SESSION["incorrect"] + 1;
$status = "false";
}
if(!empty($_POST["choice"])) {
if($_POST["choice"] == $_POST["answer"]) {
$_SESSION["correct"] = $_SESSION["correct"] + 1;
}
if($_POST["choice"] != $_POST["answer"]) {
$_SESSION["incorrect"] = $_SESSION["incorrect"] + 1;
}
$status = "true";
}
if($status == "true")
$_SESSION['correct'];
}
}


<div class="row">
<div class="col-lg-5">
<div class="panel panel-default">
<div class="panel-heading">
<h4><font color="#00CC00">Login As: <?php echo $fname." ".$lname.".";?>
</font></h4>
</div>
</font>
</div>




<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input name="set" type="hidden" value="set">

<?php
$cat = $_SESSION["question"];
$sql = "select * from question WHERE category_id='$cat' ORDER BY RAND() LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo $_SESSION[i]+1 .".) ".$row[question].NL;
$show_choice = mysql_query("SELECT * FROM choices WHERE question_id='$row[question_id]'");
while($show = mysql_fetch_array($show_choice)) {
echo "<input name=\"choice[$_SESSION[i]]\" type=\"radio\" value=\"$show[choice_1]; ?>\">".$show["choice_1"].NL;
echo "<input name=\"choice[$_SESSION[i]]\" type=\"radio\" value=\"$show[choice_2]; ?>\">".$show["choice_2"].NL;
echo "<input name=\"choice[$_SESSION[i]]\" type=\"radio\" value=\"$show[choice_3]; ?>\">".$show["choice_3"].NL;
echo "<input name=\"choice[$_SESSION[i]]\" type=\"radio\" value=\"$show[choice_4]; ?>\">".$show["choice_4"].NL;
echo "<input name=\"answer[$_SESSION[i]]\" type=\"hidden\" value=\"$show[answer]; ?>\">".NL;

$_SESSION["i"] = $_SESSION["i"] + 1;
}


?>

<input name="submit" type="submit" class="btn btn-success" value="Continue">
</form>

最佳答案

使用javascript实现:

window.setTimeout(function(event) {
$('form').submit();
}, 1000);

$('form').on('submit', function(event){
event.preventDefault();
alert('submited')
})

示例如下: http://jsfiddle.net/DariuszMusielak/3pkmb49x/1/

关于java - 如何设置定时器自动提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28382599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com