有2个问题劳烦大家帮忙
第一个
RadioButtonList rblDanxuan = new RadioButtonList();//后台生成radiobuttonlist
rblDanxuan.Attributes.Add("onclick", "changeColor('rbtnList" + num.ToString() + "')");//添加onclick事件//JS changeColor方法/
//其实这个是生成试题,然后选中的试题变色,然后统计,已经答了多少题,未答多少题
//现在除了问题,比如说第一个题,你点了一下,已答1题,剩余69,然后在点第二题,已答2题,剩余68,然后再回头点一题,变成已答3,剩余67,下面的js代码我已经做了筛选了,为什么还能重复添加var rblList=new Array();
function changeColor(rblID)
{
document.getElementById(rblID).style.backgroundColor="#DDF4DF";
var a =false;
if(rblList.length==0)
{
rblList.push(rblID);
}
else
{
for(var i=0;i<rblList.length;i++)
{
if(rblList[i]==rblID)
{
a= false;
}
else
{
a= true;//查询所点击的radiobuttonlist不在数组中
}
}
if(a)
{
rblList.push(rblID);
}
}
document.getElementById('spanRemain').innerHTML="已答:"+rblList.length+"剩余:"+(70-rblList.length);
}
问题二,比较简单,就是一个计时器,js做的考试时间60分钟,到时间自动交卷,已经做好了,问题是不能刷新,一刷新就又变成60分钟了,请教下这个有什么办法解决
下面是代码...var count=60;
function serverCurrTime() {
var str="";
if(count%60!=0){
var temp=count/60+"";
temp=temp.split(".");
str="0"+temp[0]+":"+((count%60-1)>9?count%60-1+"":"0"+(count%60-1))+":"+"59";
}else{
str="0"+((count/60>1)?(count/60-1):0)+":"+59+":"+"59";
}
document.getElementById("currTime").innerHTML = str;
setTimeout(reduceOneSec,1000);
}function reduceOneSec() {//自动减少一秒
var currTime=document.getElementById("currTime");
// alert(currTime.innerHTML);
var tempTime=currTime.innerHTML.split(":");
var hour=tempTime[0];
var minute=tempTime[1];
var second=tempTime[2];
//alert(hour+":"+minute+":"+second);
if(second>=1){
second=(second-1>9)?(second-1):"0"+(second-1);
}else{
second="59";
if(minute>=1){
minute=(minute-1>9)?(minute-1):"0"+(minute-1);
}else{
if(hour>=1){
minute="59";
hour=(hour-1>9)?(hour-1):"0"+(hour-1);
alert(hour+":"+minute) ;
}else{
minute="00";
hour="0"+0;
}
}
}
document.getElementById("currTime").innerHTML=hour+":"+minute+":"+second;
if(hour==0&&minute==0&&second==0){
qiangzhi();
}else{
setTimeout(reduceOneSec,1000);
}
}function qiangzhi()//强制交卷
{
document.all.ly.style.display="block";
document.all.ly.style.width=document.body.clientWidth;
document.all.ly.style.height=document.body.clientHeight;
document.getElementById('divQz').style.display="block";
if(qztime==0)
{
document.getElementById('imgBtnCoerce').click();
}
else
{
document.getElementById('spqzjj').innerHTML=qztime+"秒";
setTimeout(qiangzhi,1000);
}
qztime--;
}
大家帮忙看看 谢谢
第一个
RadioButtonList rblDanxuan = new RadioButtonList();//后台生成radiobuttonlist
rblDanxuan.Attributes.Add("onclick", "changeColor('rbtnList" + num.ToString() + "')");//添加onclick事件//JS changeColor方法/
//其实这个是生成试题,然后选中的试题变色,然后统计,已经答了多少题,未答多少题
//现在除了问题,比如说第一个题,你点了一下,已答1题,剩余69,然后在点第二题,已答2题,剩余68,然后再回头点一题,变成已答3,剩余67,下面的js代码我已经做了筛选了,为什么还能重复添加var rblList=new Array();
function changeColor(rblID)
{
document.getElementById(rblID).style.backgroundColor="#DDF4DF";
var a =false;
if(rblList.length==0)
{
rblList.push(rblID);
}
else
{
for(var i=0;i<rblList.length;i++)
{
if(rblList[i]==rblID)
{
a= false;
}
else
{
a= true;//查询所点击的radiobuttonlist不在数组中
}
}
if(a)
{
rblList.push(rblID);
}
}
document.getElementById('spanRemain').innerHTML="已答:"+rblList.length+"剩余:"+(70-rblList.length);
}
问题二,比较简单,就是一个计时器,js做的考试时间60分钟,到时间自动交卷,已经做好了,问题是不能刷新,一刷新就又变成60分钟了,请教下这个有什么办法解决
下面是代码...var count=60;
function serverCurrTime() {
var str="";
if(count%60!=0){
var temp=count/60+"";
temp=temp.split(".");
str="0"+temp[0]+":"+((count%60-1)>9?count%60-1+"":"0"+(count%60-1))+":"+"59";
}else{
str="0"+((count/60>1)?(count/60-1):0)+":"+59+":"+"59";
}
document.getElementById("currTime").innerHTML = str;
setTimeout(reduceOneSec,1000);
}function reduceOneSec() {//自动减少一秒
var currTime=document.getElementById("currTime");
// alert(currTime.innerHTML);
var tempTime=currTime.innerHTML.split(":");
var hour=tempTime[0];
var minute=tempTime[1];
var second=tempTime[2];
//alert(hour+":"+minute+":"+second);
if(second>=1){
second=(second-1>9)?(second-1):"0"+(second-1);
}else{
second="59";
if(minute>=1){
minute=(minute-1>9)?(minute-1):"0"+(minute-1);
}else{
if(hour>=1){
minute="59";
hour=(hour-1>9)?(hour-1):"0"+(hour-1);
alert(hour+":"+minute) ;
}else{
minute="00";
hour="0"+0;
}
}
}
document.getElementById("currTime").innerHTML=hour+":"+minute+":"+second;
if(hour==0&&minute==0&&second==0){
qiangzhi();
}else{
setTimeout(reduceOneSec,1000);
}
}function qiangzhi()//强制交卷
{
document.all.ly.style.display="block";
document.all.ly.style.width=document.body.clientWidth;
document.all.ly.style.height=document.body.clientHeight;
document.getElementById('divQz').style.display="block";
if(qztime==0)
{
document.getElementById('imgBtnCoerce').click();
}
else
{
document.getElementById('spqzjj').innerHTML=qztime+"秒";
setTimeout(qiangzhi,1000);
}
qztime--;
}
大家帮忙看看 谢谢
解决方案 »
- 关于aspnetpager分页问题
- asp新手问下关于页面载入效率问题
- DetailsView对GridView排序后读取索引值的问题
- vs2010 asp.NET 示例项目分析一个方法
- asp.net提示说无法在web服务器上启动调试,因为没有启用集成Windows身份验证。
- 怎样改变表单提交的默认地址,我用javascript改变以后提交出现“此页的视图状态无效,可能已损坏。”错误(有代码)
- 在新建立的AppDomain中动态加载Assembly的问题
- 比较时间的sql语句怎么写呀?在线等,急。
- 如何判断 我在treeview上选择的节点 是第几层?
- 怎么用javascript控制datagrid控件里模板列的文本控件
- 内网无法打开外网域名的问题,谢谢指点
- 事件触发问题
a=false时应该break了,不要再继续循环var rblList=new Array();
function changeColor(rblID)
{
document.getElementById(rblID).style.backgroundColor="#DDF4DF";
var a =false;
if(rblList.length==0)
{
rblList.push(rblID);
}
else
{
for(var i=0;i<rblList.length;i++)
{
if(rblList[i]==rblID)
{
a= false;
break;
}
else
{
a= true;//查询所点击的radiobuttonlist不在数组中
}
}
if(a)
{
rblList.push(rblID);
}
}
document.getElementById('spanRemain').innerHTML="已答:"+rblList.length+"剩余:"+(70-rblList.length);
}
这个是可以的,他是在Table上加onclick,可以满足他的需求。没必要在每个小项中添加onclick
因为radiobuttonlist 是个table 点旁边的也变色了
第二个问题,你应该 在其他地方 保存用户开始答题的时间每次的60 秒都是先读取用户开始答题的时间 ,读取到 就和当前时间作差, 没读取到 就是60秒--好这个我试试
因为radiobuttonlist 是个table 点旁边的也变色了----------------------------------------------------
出现这个问题的原因就是rblDanxuan.Attributes.Add("onclick", "changeColor('rbtnList" + num.ToString() + "')");这句的问题因为你需要将 onclick 事件 加在 radio html tag 上而不是 radio 所在的 table 上
哦 我明白了 加在items上应该就行...我试试
那就循环给ListItem加onclick
return false; }
if (event.keyCode == 116) { //屏蔽 F5
event.keyCode = 0;
event.returnValue = false;
}