想实现点击radio跳转下一题,并计分,最后给出不同结果(jsp)
java吧
全部回复
仅看楼主
level 3
IT20140207 楼主
如题,我用html做了主页面,对于选择题部分 的模块i做了15个,点击radio跳转可以做到,关键是如何计分,原理我懂,用一个变量。前两天忙着看软考没听课,现在老师叫小组做项目,就拖了后腿了。
<div id="endSelect1">
<p> </p>
<label class="label">1.如果分手后,还会跟对方做朋友吗?</label>
<p> </p>
<input type=radio name="radio1" value="1" onclick="select1()">不会<br>
<script>
function select1() {
endSelect2.style.display = 'block';
endSelect1.style.display = 'none';
endSelect3.style.display = 'none';
endSelect4.style.display = 'none';
endSelect5.style.display = 'none';
endSelect6.style.display = 'none';
endSelect7.style.display = 'none';
endSelect8.style.display = 'none';
endSelect9.style.display = 'none';
endSelect10.style.display = 'none';
endSelect11.style.display = 'none';
endSelect12.style.display = 'none';
endSelect13.style.display = 'none';
endSelect14.style.display = 'none';
endSelect15.style.display = 'none';
}
</script>
<br /> <input type=radio name="radio1" value="2"
onclick="select1()">大概会<br> <br /> <input
type=radio name="radio1" value="3" onclick="select1()">会,做不成恋人还是可以的做朋友的<br>
<br /> <br /> <input name="submit" type="button"
class="sizebutton1" value="提交" />
</div>
是我这部分的代码
2015年05月12日 03点05分 1
level 3
IT20140207 楼主
~!
2015年05月12日 03点05分 2
level 3
IT20140207 楼主
...
2015年05月12日 05点05分 3
level 11
最后一次提交再计算分数
结果可以保存在服务器上,也可以保存到客户端
2015年05月12日 05点05分 4
想法我懂。。上课没听,servlet怎么写都步晓得,就会连接个数据库。。
2015年05月12日 05点05分
@IT20140207 提交数据里包括试卷序号、当前题目序号以及结果。服务器里维护一个集合,包含保存当前试卷的结果集合。最后一次提交计分。
2015年05月12日 05点05分
回复
������������
:提取数据库先不说,按下面的代码可以吗
2015年05月12日 06点05分
level 11
这个结果直接存数据库
到这一页时读数据库,没有值就是默认什么都不选,有值就选中。
2015年05月12日 05点05分 5
level 3
IT20140207 楼主
回复 爱生活的拉风 :不会写啊不会写!~~sevelet里:
int value = Integer.valueOf(request.getParameter("radio1"));
Update reg = new Update();
reg.setId(value);
int update = UpdateService.addvalue(reg);
service里:
public static int addValue(Value reg) {
int update = 0;
Connection con = null;
PreparedStatement ps = null;
try {
con = DBUtil.getConnection();
String sql = "INSERT INTO register"
+ "(value)"
+ " VALUES(?)";
ps = con.prepareStatement(sql);
update = ps.executeUpdate();
System.out.println(update);
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtil.close(null, ps, con);
}
return update;
}
2015年05月12日 06点05分 6
1