如何创建一个10分钟的计时器,使用Javascript在HTML中自动提交表单。(空白字段在提交后自动将值设置为0)
我已经有一段时间没有处理这个jquery问题了,但是现在,我遇到了这个问题,使用jquery或javascript在HTML中创建倒计时计时器来提交表单 我在互联网上搜索了很多,甚至在这个网站上,但它并没有真正帮助我创建代码的方式。它是这样显示的如何创建一个10分钟的计时器,使用Javascript在HTML中自动提交表单。(空白字段在提交后自动将值设置为0),javascript,jquery,html,timer,Javascript,Jquery,Html,Timer,我已经有一段时间没有处理这个jquery问题了,但是现在,我遇到了这个问题,使用jquery或javascript在HTML中创建倒计时计时器来提交表单 我在互联网上搜索了很多,甚至在这个网站上,但它并没有真正帮助我创建代码的方式。它是这样显示的 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <title>GHS Applicant Exam Tool</t
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<title>GHS Applicant Exam Tool</title>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
GHS申请人考试工具
这是定时器的脚本代码
<script type="text/javascript">
var total_seconds =60*10;
var c_minutes = parseInt(total_seconds/60);
var c_seconds = parseInt(total_seconds%60);
function CheckTime(){
document.getElementById("quiz-time-left").innerHTML
='Time Left: ' + c_minutes + ' minutes ' + c_seconds + ' seconds ' ;
if(total_seconds <=0){
setTimeout('document.quiz.submit()',1);
} else{
total_seconds = total_seconds -1;
c_minutes = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds&60);
setTimeout("CheckTime()",1000);
}}
setTimeout("CheckTime()",1000);
</script>
<style>
</style>
</head>
<body>
var总秒数=60*10;
var c_minutes=parseInt(总秒数/60);
var c_seconds=parseInt(总秒数%60);
函数CheckTime(){
document.getElementById(“剩余测验时间”).innerHTML
='剩余时间:'+c_分钟+'分钟'+c_秒+'秒';
if(总_秒<代码>功能检查时间(){
document.getElementById(“剩余测验时间”).innerHTML
='剩余时间:'+c_分钟+'分钟'+c_秒+'秒';
if(总_秒<代码>功能检查时间(){
document.getElementById(“剩余测验时间”).innerHTML
='剩余时间:'+c_分钟+'分钟'+c_秒+'秒';
if(total_seconds)我应该将其添加到脚本标记上吗?还是使用此标记替换它?将其替换为urs。我应该将其添加到脚本标记上吗?还是使用此标记替换它?将其替换为urs。
<div class="content">
<div style="font-weight: bold" id="quiz-time-left"></div>
<center><h3>GHS Applicant Assessment Tool</h3></center>
<h5><p>This exam is an assessment tool to help us place you in the correct account.</p></h5>
<p>* Required</p><br>
<form name="quiz" id="myquiz" onsubmit="return validate()" method="post" action="/ghs/ghsadd.php"
enctype="multipart/form-data">
Last name*<br>
<input type="text" name="last_name" ><br>
First name*<br>
<input type="text" name="first_name" ><br>
Middle Initial<br>
<input type="text" name="middle_initial" ><br><br>
<p>Highest Educational Attainment*</p>
<input type="radio" name="educ_attain" value="hsalsgrad"> High School Graduate / ALS Graduate<br>
<input type="radio" name="educ_attain" value="shsgrad"> Senior High School Graduate<br>
<input type="radio" name="educ_attain" value="undergrad1"> College Undergraduate 1 year<br>
<input type="radio" name="educ_attain" value="undergrad2"> College Undergraduate 2 years<br>
<input type="radio" name="educ_attain" value="undergrad3"> College Undergraduate 3 years<br>
<input type="radio" name="educ_attain" value="undergrad4"> College Undergraduate 4+ years<br>
<input type="radio" name="educ_attain" value="collegegrad"> College Graduate<br>
<hr>
<p>Logic and Reasoning</p>
<p>You will be given 5 minutes to complete this portion.</p><br>
<p>The 4:25 P2P bus takes 1 hour and 45 minutes to arrive in
Trinoma. If Joseph takes this bus, what time will he arrive in
Trinoma? *</p>
<input type="radio" name="logic1" value="0" required> 7:05 <br>
<input type="radio" name="logic1" value="0" required> 6:25<br>
<input type="radio" name="logic1" value="1" required> 6:10<br>
<input type="radio" name="logic1" value="0" required> 5:55<br>
<br>
<p>Janine’s shoes cost $44.50, her pants cost $20.80 and her t-shirt
cost $14.95. What is the total of her purchases? *</p>
<input type="radio" name="logic2" value="0" required> 85.25<br>
<input type="radio" name="logic2" value="1" required> 80.25<br>
<input type="radio" name="logic2" value="0" required> 82.55<br>
<input type="radio" name="logic2" value="0" required> 80.55<br>
<input name="submit" name="submitbutton" type="submit" value="Submit"></input>
</form>
function CheckTime(){
document.getElementById("quiz-time-left").innerHTML
='Time Left: ' + c_minutes + ' minutes ' + c_seconds + ' seconds ' ;
if(total_seconds <=0){
clearInterval(intervalVariable);
$("#submit_button_id").click()
} else{
total_seconds = total_seconds -1;
c_minutes = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds&60);
}}
var intervalVariable = setInterval(CheckTime,1000)