帖子页后页面丢失了一部分

时间:2015-03-17 22:19:53

标签: javascript html asp.net

点击this page中的开始后,该值将丢失。

我该怎么办,为了不让页面重新加载?

<button onclick="start()">Start</button>

开始:当用户在设置屏幕上单击“开始”时调用此方法

function start(reuse){
    reuse = (typeof reuse === 'undefined') ? false : true;

    //user input is read
    numberOfQuestions = $("#amount").val();
    time = $("#time").val();
    showError = $("#showError").prop("checked");
    showCorrect = $("#showCorrect").prop("checked");
    fullscreen = $("#fullscreen").prop("checked");

    //currentIndex is the index of current question in the list while in the quiz
    currentIndex = -1;

    //reset correct questions
    correct = 0;


    var pred = {place:1, time:2, other:3};
    var _numberOfQuestions = 0;

    if (reuse){
        _data = filteredData;
    } else {
        _data = data;
    }

    //filteredData is the new list of question AFTER filtering it according to setup screen
    filteredData = [];

    $.each(_shuffle(_data), function(index, entry){
        if ($("#ddcl-d1-i"+entry['pad']).prop("checked")){
            if ($("#ddcl-d2-i"+pred[entry['pred']]).prop("checked")){
                _numberOfQuestions++;
                entry['a'] = _shuffle(entry['a']);
                filteredData.push(entry);
            }
        }
        if (_numberOfQuestions == numberOfQuestions) return false;
    });
    if (_numberOfQuestions == 0){
        alert("No questions available");
        return;
    }

    $("#quiz").show();
    $("#setup").hide();
    $("#finish").hide();

    secondsLeft = time * numberOfQuestions;
    doTimer();

    nextQuestion();

    if (fullscreen && screenfull.enabled){
        screenfull.request(document.getElementById('container'));
    }
}

我用JavaScript调用Start

我尝试添加autopostback ="false",但结果仍然相同。

1 个答案:

答案 0 :(得分:0)

您可以将类型属性添加到按钮,因为它们会自动提交表单。

<button type="button" onclick="start()">Start</button>