int num 的数据类型在<c:forEach var="li" items="${sessionScope.list}"> ${li.num}</c:forEach>循环出来
如 num=100 num=200 num=300。。。
怎么在页面定时相加
如 第1秒num=100
第2秒 num=300
第3秒 num=600
在页面上显示
在线求解
------解决思路----------------------
1.定时刷新整个页面
2.定时ajax请求,然后改页面
3.flash或者其他技术
------解决思路----------------------
是这一个意思吗?
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = test;
var sh;
function test() {
sh = window.setInterval(show, 1000);
}
var x = [100, 200, 300], t = 0;
var num = 0;
function show() {
if (t == x.length) {
clearInterval(sh);
return;
}
num += x[t];
t++;
document.getElementById("dd").value = num;
}
</script>
</head>
<body>
<input id="dd" type="text" value=''/>
</body>
</html>
------解决思路----------------------
嗯
<script>
window.onload = test;
var sh;
function test() {
sh = window.setInterval(show, 1000);
}
var x=[];
<c:forEach var="li" items="${sessionScope.list}">
x.push('${li.num}');
</c:forEach>
var t = 0;
var num = 0;
function show() {
if (t == x.length) {
clearInterval(sh);
return;
}
num += x[t];
t++;
document.getElementById("dd").value = num;
}
</script>
------解决思路----------------------
那你就转换下。