好的,我对javascript不太满意,只是开始学习它。我所有的形式都可以使用,但是我想做的是,如果某人在1分钟内未回答此测验中的任何问题,它将提交未回答的值。让我们将该值称为“ e”。因此,在我的输入中,我具有值a,b,c,d,如果他们在一分钟内未回答,我希望它提交值“ e”。现在,表单已提交,但是我尝试了多种方法来尝试使其带有值,但是它不起作用
任何帮助将不胜感激。谢谢。
<div id="quiz">
<form method="post" id="test" name="test" action="<?php $user_answers->set_user_answers_action();?>">
<p>
<?php echo $test_questions->set_question(); ?>
</p>
<input type="hidden" id="answer" name="answer" value="<?php $user_answers->set_user_answers_field();?>">
<input type="hidden" id="number_of_questions" name="number_of_questions" value="<?php echo $number_of_questions; ?>">
<input type="radio" id="answerv" name="answerv" value="a" required>a)
<?php echo $test_questions->set_answer_a(); ?><br>
<input type="radio" id="answerv" name="answerv" value="b" required>b)
<?php echo $test_questions->set_answer_b(); ?><br>
<input type="radio" id="answerv" name="answerv" value="c" required>c)
<?php echo $test_questions->set_answer_c(); ?><br>
<input type="radio" id="answerv" name="answerv" value="d" required>d)
<?php echo $test_questions->set_answer_d(); ?><br>
<input type="submit" value="<?php $user_answers->set_user_answers_submit(); echo $user_answers->submit; ?>">
</form>
</div>
<div style="font-weight: bold" id="quiz-time-left"></div>
<script type="text/javascript">
var max_time = 1;
var c_seconds = 0;
var total_seconds = 60 * max_time;
max_time = parseInt(total_seconds / 60);
c_seconds = parseInt(total_seconds % 60);
document.getElementById("quiz-time-left").innerHTML = 'Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
function init() {
document.getElementById("quiz-time-left").innerHTML = 'Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
setTimeout("CheckTime()", 999);
}
function CheckTime() {
document.getElementById("quiz-time-left").innerHTML = 'Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
if (total_seconds <= 0) {
setTimeout('document.test.submit()', 1);
} else {
total_seconds = total_seconds - 1;
max_time = parseInt(total_seconds / 60);
c_seconds = parseInt(total_seconds % 60);
setTimeout("CheckTime()", 999);
}
}
init();
</script>
答案 0 :(得分:2)
您可以添加
<input type="radio" name="answerv" value="e" style="display:none" checked>
在您的表单中无处不在。