我需要根據超時定時器提交表單。它不是調用表單提交。請給我建議JavaScript setInterval調用form.submit
我打電話的document.ready
$(document).ready(function(){
var duration = 60*20;
display = $('#timer');
startTimer(duration, display);
$.fn.disableSelection = function() {
return this
.attr('unselectable', 'on')
.css('user-select', 'none')
.on('selectstart', false);
};
$("#question_container").disableSelection();
});
function startTimer(duration, display) {
var timer = duration, minutes, seconds;
setInterval(function()
{
minutes = parseInt(timer/60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.text(minutes + ":" + seconds);
if (--timer < 0) {
$("#questionform").submit();
}
}, 1000);
}
setInterval ("autosubmit()", 5000000);
function autosubmit()
{
document.theFormName.submit;
}
什麼是'autosubmit'?它的定義在哪裏? – hindmost
我已添加自動提交代碼 –
控制檯中的任何錯誤? – kulaeff