求一段js代码(读取表单信息),急啊,时间紧。。谢谢啦 var strTemp = document.form1.input.value 什么啊?是这个么 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <INPUT TYPE=checkbox value=题号>题目内容页面上写个循环将选中的题号拼起来,用个<input type=hidden>存提交到另外页面后split出来,然后展现 你运气好,我刚写了这么一个东西!给我分吧,我现在缺分------------------<html><head><title>测试系统--Powered by FriedChicken</title><style type="text/css">body,td,th { font-size: 14px;}</style><script language="javascript">var answer=new Array(); //问题的标准答案var wrong=new Array();function addAnswer(_answer){ //输入标准答案 answer=_answer.toUpperCase().split(" ");}function totalScoring(){ wrong.length=0; var score=0; for(i=0;i<answer.length;i++){ var _score=0; //该题的得分 var t=document.getElementsByName('question'+(i+1)); //获得该题的所有选项 var bad_answer=false; var no_check=true; for(j=0;j<t.length;j++){ //逐个检查选项是否被选中 if(t[j].checked){ no_check=false; if(answer[i].indexOf(String.fromCharCode("A".charCodeAt(0)+j))==-1){//如果选错,不给分 bad_answer=true; break; } } } if(!bad_answer && !no_check){ //如果选中的选项都属于正确答案,则继续检查是否漏选。 _score=8; //如果完全正确,拿8分 for(j=0;j<answer[i].length;j++){ if(t[answer[i].charAt(j).charCodeAt(0)-"A".charCodeAt(0)].checked==false){//如果还有正确答案没有选的 _score=4; //可以拿4分 wrong[wrong.length]=i; //记录下题号 break; } } } else{ wrong[wrong.length]=i; //记录下答错的题号 } score+=_score; } //打印出得分和答错题目的答案 var display="你的得分是"+score+"\n\n"; for(i=0;i<wrong.length;i++){ display+=("第"+(wrong[i]+1)+"题的正确答案是:"+answer[wrong[i]]+"\n"); } document.getElementById("score_display").innerText=display;}</script><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><script language="javascript">addAnswer("A B C D A B C D ABCD ABC AB A");</script><!--在输入正确答案,用空格分开--><table width="50%" border="1" align="center" cellpadding="10" cellspacing="5" bordercolor="#FFCC99" bgcolor="#FFFFCC"> <tr> <td><p>你好,如下问题只有一个选项是正确答案。</p> <p>回答正确给8分,答错不得分。</p></td> </tr> <tr> <td width="21%">1、测试题描述.................<br> <input type="radio" name="question1"> A. 选项一<br> <input type="radio" name="question1">B. 选项二<br><input type="radio" name="question1">C. 选项三<br><input type="radio" name="question1">D. 选项四</td> </tr> <tr> <td>2、测试题描述.................<br> <input type="radio" name="question2">A. 选项一<br><input type="radio" name="question2">B. 选项二<br><input type="radio" name="question2">C. 选项三<br><input type="radio" name="question2">D. 选项四</td> </tr> <tr> <td>3、测试题描述.................<br> <input type="radio" name="question3">A. 选项一<br><input type="radio" name="question3">B. 选项二<br><input type="radio" name="question3">C. 选项三<br><input type="radio" name="question3">D. 选项四</td> </tr> <tr> <td>4、测试题描述.................<br> <input type="radio" name="question4">A. 选项一<br><input type="radio" name="question4">B. 选项二<br><input type="radio" name="question4">C. 选项三<br><input type="radio" name="question4">D. 选项四</td> </tr> <tr> <td>5、测试题描述.................<br> <input type="radio" name="question5">A. 选项一<br><input type="radio" name="question5">B. 选项二<br><input type="radio" name="question5">C. 选项三<br><input type="radio" name="question5">D. 选项四</td> </tr> <tr> <td>6、测试题描述.................<br> <input type="radio" name="question6">A. 选项一<br><input type="radio" name="question6">B. 选项二<br><input type="radio" name="question6">C. 选项三<br><input type="radio" name="question6">D. 选项四</td> </tr> <tr> <td>7、测试题描述.................<br> <input type="radio" name="question7">A. 选项一<br><input type="radio" name="question7">B. 选项二<br><input type="radio" name="question7">C. 选项三<br><input type="radio" name="question7">D. 选项四</td> </tr> <tr> <td>8、测试题描述.................<br> <input type="radio" name="question8">A. 选项一<br><input type="radio" name="question8">B. 选项二<br><input type="radio" name="question8">C. 选项三<br><input type="radio" name="question8">D. 选项四</td> </tr> <tr> <td><p>你好,如下问题至少有一个选项是正确答案。</p> <p>回答完全正确给8分,只答对部分选项给4分,只要有一项答错不得分。</p></td> </tr> <tr> <td>9、测试题描述.................<br> <input type="checkbox" name="question9">A. 选项一<br><input type="checkbox" name="question9">B. 选项二<br><input type="checkbox" name="question9">C. 选项三<br><input type="checkbox" name="question9">D. 选项四</td> </tr> <tr> <td>10、测试题描述.................<br> <input type="checkbox" name="question10">A. 选项一<br><input type="checkbox" name="question10">B. 选项二<br><input type="checkbox" name="question10">C. 选项三<br><input type="checkbox" name="question10">D. 选项四</td> </tr> <tr> <td>11、测试题描述.................<br> <input type="checkbox" name="question11">A. 选项一<br><input type="checkbox" name="question11">B. 选项二<br><input type="checkbox" name="question11">C. 选项三<br><input type="checkbox" name="question11">D. 选项四</td> </tr> <tr> <td>12、测试题描述.................<br> <input type="checkbox" name="question12">A. 选项一<br><input type="checkbox" name="question12">B. 选项二<br><input type="checkbox" name="question12">C. 选项三<br><input type="checkbox" name="question12">D. 选项四</td> </tr> <tr> <td><div align="right"> <input type="button" name="Submit" value="交卷" style="width:100px; height:27; background:#FF6633; color:#FFFFFF" onClick="totalScoring();"> </div></td> </tr> <tr> <td id="score_display">完成后,请点击<交卷>按钮,看看你得了多少分。</td> </tr></table></body></html>---------------------用addAnswer方法设置题目答案(只能用字母) js弹出新窗口,如果让其显示在屏幕中间? 求一个正则(多行模式) 新手问题!!!!! 这个效果的js怎么做? 这个效果如何实现啊?帮帮忙! 校验输入的必须是 数字遇到的 问题! 但切换输入法之后??? table===>excel 請大家幫我看看這段代碼的意思 如何将WSH(windows Scripting Host)应用于网页中? css、js如何实现单页切换? 简单问题,达人乱入(50) 帮我理解下这段小白
------------------
<html>
<head>
<title>测试系统--Powered by FriedChicken</title>
<style type="text/css">body,td,th {
font-size: 14px;
}
</style>
<script language="javascript">
var answer=new Array(); //问题的标准答案
var wrong=new Array();function addAnswer(_answer){ //输入标准答案
answer=_answer.toUpperCase().split(" ");
}function totalScoring(){
wrong.length=0;
var score=0;
for(i=0;i<answer.length;i++){
var _score=0; //该题的得分
var t=document.getElementsByName('question'+(i+1)); //获得该题的所有选项 var bad_answer=false;
var no_check=true;
for(j=0;j<t.length;j++){ //逐个检查选项是否被选中
if(t[j].checked){
no_check=false;
if(answer[i].indexOf(String.fromCharCode("A".charCodeAt(0)+j))==-1){//如果选错,不给分
bad_answer=true;
break;
}
}
}
if(!bad_answer && !no_check){ //如果选中的选项都属于正确答案,则继续检查是否漏选。
_score=8; //如果完全正确,拿8分
for(j=0;j<answer[i].length;j++){
if(t[answer[i].charAt(j).charCodeAt(0)-"A".charCodeAt(0)].checked==false){//如果还有正确答案没有选的
_score=4; //可以拿4分
wrong[wrong.length]=i; //记录下题号
break;
}
}
}
else{
wrong[wrong.length]=i; //记录下答错的题号
}
score+=_score;
}
//打印出得分和答错题目的答案
var display="你的得分是"+score+"\n\n";
for(i=0;i<wrong.length;i++){
display+=("第"+(wrong[i]+1)+"题的正确答案是:"+answer[wrong[i]]+"\n");
}
document.getElementById("score_display").innerText=display;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<script language="javascript">addAnswer("A B C D A B C D ABCD ABC AB A");</script><!--在输入正确答案,用空格分开-->
<table width="50%" border="1" align="center" cellpadding="10" cellspacing="5" bordercolor="#FFCC99" bgcolor="#FFFFCC">
<tr>
<td><p>你好,如下问题只有一个选项是正确答案。</p>
<p>回答正确给8分,答错不得分。</p></td>
</tr>
<tr>
<td width="21%">1、测试题描述.................<br>
<input type="radio" name="question1">
A. 选项一<br>
<input type="radio" name="question1">
B. 选项二<br>
<input type="radio" name="question1">
C. 选项三<br>
<input type="radio" name="question1">
D. 选项四</td>
</tr>
<tr>
<td>2、测试题描述.................<br>
<input type="radio" name="question2">
A. 选项一<br>
<input type="radio" name="question2">
B. 选项二<br>
<input type="radio" name="question2">
C. 选项三<br>
<input type="radio" name="question2">
D. 选项四</td>
</tr>
<tr>
<td>3、测试题描述.................<br>
<input type="radio" name="question3">
A. 选项一<br>
<input type="radio" name="question3">
B. 选项二<br>
<input type="radio" name="question3">
C. 选项三<br>
<input type="radio" name="question3">
D. 选项四</td>
</tr>
<tr>
<td>4、测试题描述.................<br>
<input type="radio" name="question4">
A. 选项一<br>
<input type="radio" name="question4">
B. 选项二<br>
<input type="radio" name="question4">
C. 选项三<br>
<input type="radio" name="question4">
D. 选项四</td>
</tr>
<tr>
<td>5、测试题描述.................<br>
<input type="radio" name="question5">
A. 选项一<br>
<input type="radio" name="question5">
B. 选项二<br>
<input type="radio" name="question5">
C. 选项三<br>
<input type="radio" name="question5">
D. 选项四</td>
</tr>
<tr>
<td>6、测试题描述.................<br>
<input type="radio" name="question6">
A. 选项一<br>
<input type="radio" name="question6">
B. 选项二<br>
<input type="radio" name="question6">
C. 选项三<br>
<input type="radio" name="question6">
D. 选项四</td>
</tr>
<tr>
<td>7、测试题描述.................<br>
<input type="radio" name="question7">
A. 选项一<br>
<input type="radio" name="question7">
B. 选项二<br>
<input type="radio" name="question7">
C. 选项三<br>
<input type="radio" name="question7">
D. 选项四</td>
</tr>
<tr>
<td>8、测试题描述.................<br>
<input type="radio" name="question8">
A. 选项一<br>
<input type="radio" name="question8">
B. 选项二<br>
<input type="radio" name="question8">
C. 选项三<br>
<input type="radio" name="question8">
D. 选项四</td>
</tr>
<tr>
<td><p>你好,如下问题至少有一个选项是正确答案。</p>
<p>回答完全正确给8分,只答对部分选项给4分,只要有一项答错不得分。</p></td>
</tr>
<tr>
<td>9、测试题描述.................<br>
<input type="checkbox" name="question9">
A. 选项一<br>
<input type="checkbox" name="question9">
B. 选项二<br>
<input type="checkbox" name="question9">
C. 选项三<br>
<input type="checkbox" name="question9">
D. 选项四</td>
</tr>
<tr>
<td>10、测试题描述.................<br>
<input type="checkbox" name="question10">
A. 选项一<br>
<input type="checkbox" name="question10">
B. 选项二<br>
<input type="checkbox" name="question10">
C. 选项三<br>
<input type="checkbox" name="question10">
D. 选项四</td>
</tr>
<tr>
<td>11、测试题描述.................<br>
<input type="checkbox" name="question11">
A. 选项一<br>
<input type="checkbox" name="question11">
B. 选项二<br>
<input type="checkbox" name="question11">
C. 选项三<br>
<input type="checkbox" name="question11">
D. 选项四</td>
</tr>
<tr>
<td>12、测试题描述.................<br>
<input type="checkbox" name="question12">
A. 选项一<br>
<input type="checkbox" name="question12">
B. 选项二<br>
<input type="checkbox" name="question12">
C. 选项三<br>
<input type="checkbox" name="question12">
D. 选项四</td>
</tr>
<tr>
<td><div align="right">
<input type="button" name="Submit" value="交卷" style="width:100px; height:27; background:#FF6633; color:#FFFFFF" onClick="totalScoring();">
</div></td>
</tr>
<tr>
<td id="score_display">完成后,请点击<交卷>按钮,看看你得了多少分。</td>
</tr>
</table>
</body></html>
---------------------
用addAnswer方法设置题目答案(只能用字母)