javascript在线考试网页代码
<scriptlanguage="JavaScript"type="text/javascript">varquestion_number=5;varanswer="";...
<script language="JavaScript" type="text/javascript">
var question_number=5;
var answer=" ";
var msg=" ";
var solution=new Array(question_number);
solution[0]="_blank";
solution[1]="热点";
solution[2]="F12";
solution[3]="记事本程序";
solution[4]=".dwt";
function grade(){
var correct=0;
var wrong=0;
for(number=0;number<question_number;number++){
var j=0;
var form1=document.forms[number];
var i=getSelectedNumber(form1.RadioGroup1);
if (i!=-1&&form1.RadioGroup1[i].value=="1") correct++;
else{
wrong++;
answer+="第"+(number+1)+"题:"+solution[number]+"<br>";
}
}
reportScore(correct);
}
function getSelectedNumber(radioButtion){
for(j=0;j<radioButton.length;j++)
if (radioButton[j].checked) return j;
return -1;
}
function reportScore(correct){
var score=correct/question_number*100;
var reportWindow
=window.open("", "","scrollbars,resizable=1,width=350,height=280");
reportWindow.document.write("<html><head><title>测试成绩报告
</title></head><body>");
reportWindow.document.write("<h4>你的测试成绩是: "+score+"<br>");
if (score=="100")
msg="<font color='red'>祝贺你答对了!</font><p>";
else
msg="<font color='red'>错误题目的正确答案是: </font><p>"+answer;
msg+="<br><input type=button' value='关闭窗口'
onclick='javascript:window.close()'>";
reportWindow.document.write(msg);
reportWindow.document.write("</body></html">;
msg=" ";
answer=" ";
}
</script>
下面的表单命名都对,为什么效果出不来啊,
求高手解释下
谢谢了 展开
var question_number=5;
var answer=" ";
var msg=" ";
var solution=new Array(question_number);
solution[0]="_blank";
solution[1]="热点";
solution[2]="F12";
solution[3]="记事本程序";
solution[4]=".dwt";
function grade(){
var correct=0;
var wrong=0;
for(number=0;number<question_number;number++){
var j=0;
var form1=document.forms[number];
var i=getSelectedNumber(form1.RadioGroup1);
if (i!=-1&&form1.RadioGroup1[i].value=="1") correct++;
else{
wrong++;
answer+="第"+(number+1)+"题:"+solution[number]+"<br>";
}
}
reportScore(correct);
}
function getSelectedNumber(radioButtion){
for(j=0;j<radioButton.length;j++)
if (radioButton[j].checked) return j;
return -1;
}
function reportScore(correct){
var score=correct/question_number*100;
var reportWindow
=window.open("", "","scrollbars,resizable=1,width=350,height=280");
reportWindow.document.write("<html><head><title>测试成绩报告
</title></head><body>");
reportWindow.document.write("<h4>你的测试成绩是: "+score+"<br>");
if (score=="100")
msg="<font color='red'>祝贺你答对了!</font><p>";
else
msg="<font color='red'>错误题目的正确答案是: </font><p>"+answer;
msg+="<br><input type=button' value='关闭窗口'
onclick='javascript:window.close()'>";
reportWindow.document.write(msg);
reportWindow.document.write("</body></html">;
msg=" ";
answer=" ";
}
</script>
下面的表单命名都对,为什么效果出不来啊,
求高手解释下
谢谢了 展开
3个回答
展开全部
至少你帖出来的这段代码中的
reportWindow.document.write("</body></html">;
是错误的,应该是:
reportWindow.document.write("</body></html>");
reportWindow.document.write("</body></html">;
是错误的,应该是:
reportWindow.document.write("</body></html>");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
msg+="<br><input type=button' value='关闭窗口'
onclick='javascript:window.close()'>";
看看这个是不是用问题
onclick='javascript:window.close()'>";
看看这个是不是用问题
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询