<inputtype= "hidden"value= "@ (model.timelength)"ID= "Examtimelength" /> <inputtype= "hidden"value= "@ViewData ["Examid "]" ID= "_controlerid" /> <spanID= "@ViewData ["Examid "]" class= "Fas_time"></span> <aclass= "Fas_submit"ID= "Submitexam"href="#"style= "Display:none">I need to get it.</a>
functiontimer () {varTime = $ ("#examTimeLength"). Val (); varTimer ={controleid: $ ("#_ControlerId"). Val (), CookieName: $ ("#_ControlerId"). Val (), Itotaltime:NULL, Timerid:NULL, Init:function () { This. Remaintime (); }, Addzero:function(num) {varstr = num < 10? Number (num) <= 0? ' xx ': ' 0 ' + num:num + '; returnstr; }, Remaintime:function () { var_this = This, Ospan=document.getElementById (_this.controleid); _this.timerid= SetInterval (function() {_this.itotaltime=Time ; if(_this.itotaltime <= 0) {clearinterval (_this.timerid); varfunctionname = "Submitanswer"; if(functionname) {eval (functionname+ "()"); } return; } _this.itotaltime--; time--; varHours = _this.addzero (Math.floor (_this.itotaltime/3600)); varminutes = _this.addzero (Math.floor (_this.itotaltime-hours * 3600)/60)); varsecs = _this.addzero (Math.floor (_this.itotaltime% 60)); varstr = ' {h}:{m}:{s} '; STR= Str.replace (' {h} ', hours); STR= Str.replace (' {m} ', minutes); STR= Str.replace (' {s} ', secs); Ospan.innerhtml=str; }, 1000); } }; Timer.init (); }
ASP. NET razor automatically generated JS Timer