我该如何对所取的值是个空值进行循环判断?

先在answer.asp中,把在四个checkbox中所取的值

1x=0
1do while not rs.eof
1<form action="grade.asp" method="post">
2<p align="left">   

x=x+1 ="("

1=cstr(x)

=")"

1&lt;table bgcolor="#F4FFF4" border="0" width="100%"&gt;
2&lt;input name="checkanswer" type="checkbox" value="a"/&gt;//checkbox按钮A   
3..   
4&lt;td ```&nbsp;&nbsp;<="" choicea")="" height="26```
5=rs(" td="" width="18%"&gt;   
6...   
7&lt;input name="checkanswer" type="checkbox" value="b"/&gt;"//checkbox按钮B   
8...   

=rs("choiceb")

1....   
2&lt;input name="checkanswer" type="checkbox" value="c"/&gt;//checkbox按钮c   

=rs("choicec")

1...   
2&lt;input name="checkanswer" type="checkbox" value="d"/&gt;   
3...   

=rs("choiced")

1&lt;/table&gt;   

rs.movenext
loop

1  
2然后提交到GRADE.ASP   
3  

x=0 do while not rs.eof For each dati in Request.Form("checkanswer")

1&lt;p&gt; ```
2x=x+1
3``` ```
4="("

=cstr(x)

 1=")"
 2``` ```
 3   
 4if rs.Fields("answer")="" then   
 5Response.write "请确定作完后再提交测试"&amp;"<br/>"   
 6end if   
 7if rs.Fields("answer")=dati then   
 8Response.write "正确"&amp;"<br/>"   
 9else   
10Response.write "错误"&amp;"<br/>"   
11end if   
12  
13rs.movenext   
14Next   
15loop   
16
17```   
18  
19现在问题是当四个按钮在ANSWER.ASP中全部选择后,在GRADE中比较问题。但是如果不选就出现以下:   
20\---------------------------------------------------------------   
21  
22在answer.asp中进行判断checkbox是否被选中(做了一些修改):   
23&lt;head&gt;
24&lt;script language="javascript"&gt;   
25function che(thoForm){   
26if (thoForm.form1.checkanswer.value=="" )   
27alert("请选择值!");   
28return false;   
29}   
30&lt;/script&gt;
31&lt;/head&gt;   
32```
33x=0
34```   
35```
36do while not rs.eof
37```   
38&lt;form action="grade.asp" method="post" name="form1" onsubmit="return che(this)"&gt;
39&lt;p align="left"&gt;   
40```
41x=x+1
42``` ```
43="("

=cstr(x)

 1=")"
 2```   
 3&lt;table bgcolor="#F4FFF4" border="0" width="100%"&gt;
 4&lt;input name="checkanswer" type="checkbox" value="a"/&gt;//checkbox按钮A   
 5..   
 6&lt;td ```&nbsp;&nbsp;<="" choicea")="" height="26```
 7=rs(" td="" width="18%"&gt;   
 8...   
 9&lt;input name="checkanswer" type="checkbox" value="b"/&gt;"//checkbox按钮B   
10...   
11```
12=rs("choiceb")
13```     
14....   
15&lt;input name="checkanswer" type="checkbox" value="c"/&gt;//checkbox按钮c   
16```
17=rs("choicec")
18```  &lt;/td&gt;   
19...   
20&lt;input name="checkanswer" type="checkbox" value="d"/&gt;   
21...   
22```
23=rs("choiced")
24``` 
25&lt;/table&gt;   
26```
27   
28rs.movenext   
29loop   
30
31```&lt;/p&gt;&lt;/form&gt;&lt;/p&gt;&lt;/p&gt;&lt;/form&gt;
32```
Published At
Categories with Web编程
comments powered by Disqus