zoukankan      html  css  js  c++  java
  • 与考试相关的JS方法

    var IsChange = 0;
    var ensure = 0;



    var
    timeCounter = (function () {//考试剩余时间 倒计时 var int; //var total = 3600;//1小时 var ExamTime = $("[id$='hid_ExamTime']").val();//考试时间 分钟 //alert(ExamTime); var total = ExamTime * 60; return function (elemID) { obj = document.getElementById(elemID); var s = (total % 60) < 10 ? ('0' + total % 60) : total % 60;// var h = total / 3600 < 10 ? ('0' + parseInt(total / 3600)) : parseInt(total / 3600);// var m = (total - h * 3600) / 60 < 10 ? ('0' + parseInt((total - h * 3600) / 60)) : parseInt((total - h * 3600) / 60);// obj.innerHTML = '剩余时间 ' + h + ' : ' + m + ' : ' + s; total--; int = setTimeout("timeCounter('" + elemID + "')", 1000); if (total < -1) { clearTimeout(int); if (window.confirm('考试时间结束,请确认交卷')) { //PostAnswer(); } } } })()

    调用这个JS方法

    function Load() {
                    timeCounter('timeCounter');
    
                    //设置页面自动保存
                    //setTimeout("btnSave()", 10);
                }

    提交答案

     function PostAnswer() {
                    try {
                        ensure = 1;
                        $("[id$='btnSubmitExam']").click();//触发提交按钮事件
                        //alert(111);
    
                    }
                    catch (err) { alert(err); }
                }

    答完的题目,答题卡切换颜色

    function ChangeStatus(Guid) {//改变右侧题目栏题目状态,做完的题目增加 finished 样式
                    try {
                        IsChange = 1;
    
                        $("#AnswerSheet ul li").each(function () {
                            //alert($(this).attr("ID"));
                            if ($(this).attr("ID") == Guid) {
                                //alert($(this).attr("ID"));
                                $(this).addClass('finished');
                            }
                        })
                    }
                    catch (error) {
                        alert('题目切换颜色Js出错,具体错误:' + error);
                    }
                }
    //防止复制和粘贴
    
                document.oncontextmenu = new Function("event.returnValue=false");
                document.onselectstart = new Function("event.returnValue=false");


    考试时间还没有结束,提前交卷

    function SubmitAnswer() {
                    if (window.confirm('考试结束时间还没有到,你确定要交卷?')) {
                        PostAnswer();
                    }
                }
  • 相关阅读:
    初认识AngularJS
    (imcomplete) UVa 10127 Ones
    UVa 10061 How many zero's and how many digits?
    UVa 11728 Alternate Task
    UVa 11490 Just Another Problem
    UVa 10673 Play with Floor and Ceil
    JSON对象和字符串的收发(JS客户端用typeof()进行判断非常重要)
    HTML.ActionLink 和 Url.Action 的区别
    EASYUI TREE得到当前节点数据的GETDATA方法
    jqueery easyui tree把已选中的节点数据拼成json或者数组(非常重要)
  • 原文地址:https://www.cnblogs.com/lyhsblog/p/6024337.html
Copyright © 2011-2022 走看看