F
ff_ff
Unregistered / Unconfirmed
GUEST, unregistred user!
<%
int count = 0;
String type1 = (String)session.getAttribute("type"
System.out.println("type:"
+ type1);
try{
String sql = "select count(id) as max from question where type = '"+type1+"'";
ResultSet rs = con.query(sql);
rs.next();
count = rs.getInt("max"
rs.close();
}catch(Exception e){
e.printStackTrace();
}
System.out.println("count:"
+ count);
%>
这里得到了题目总数,
可是在脚本中
<script language="javascript">
function total()
{
var total = new Array(4);
for (var n = 0;n<4;n++)
{
total[n] = 0;
}
var length = count;//这里好像不行啊.
for(var i = 1;i<=length;i++)
{
for(var j = 0;j<4;j++)
{
if(document.getElementsByName(""+i)[j].checked)
{
total[j]+=1;
}
}
}
alert("total="+total);
for(var m = 0;m<4;m++)
{
if(total[m] == length)
{
alert("输入不合法!"
return false;
}
}
alert("校验成功!"
return true;
}
</script>
暂时没有,先记上
急,谢谢.
int count = 0;
String type1 = (String)session.getAttribute("type"
System.out.println("type:"
+ type1);
try{
String sql = "select count(id) as max from question where type = '"+type1+"'";
ResultSet rs = con.query(sql);
rs.next();
count = rs.getInt("max"
rs.close();
}catch(Exception e){
e.printStackTrace();
}
System.out.println("count:"
+ count);
%>
这里得到了题目总数,
可是在脚本中
<script language="javascript">
function total()
{
var total = new Array(4);
for (var n = 0;n<4;n++)
{
total[n] = 0;
}
var length = count;//这里好像不行啊.
for(var i = 1;i<=length;i++)
{
for(var j = 0;j<4;j++)
{
if(document.getElementsByName(""+i)[j].checked)
{
total[j]+=1;
}
}
}
alert("total="+total);
for(var m = 0;m<4;m++)
{
if(total[m] == length)
{
alert("输入不合法!"
return false;
}
}
alert("校验成功!"
return true;
}
</script>
暂时没有,先记上
急,谢谢.