<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
<title>无标题文档</title>
<script type=
"text/javascript"
>
window.onload =
function
() {
var
obj = document.getElementsByName(
'abc[]'
);
var
obj_count = document.getElementById(
'count'
);
for
(
var
i = 0; i < obj.length; i ++) {
obj[i].onkeyup =
function
() {
var
count
= 0;
for
(
var
j = 0; j < obj.length; j ++) {
var
v = parseInt(obj[j].value) || 0;
count
+= v;
}
obj_count.innerHTML =
count
;
}
}
}
</script>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<input type=
"text"
name=
"abc[]"
value=
""
>
<br>
<div id=
"count"
></div>
<br><font color=
"#e78608"
>------解决方案--------------------</font><br>用parseFloat()代替parseInt()
<br><font color=
"#e78608"
>------解决方案--------------------</font><br>额,可以js算好再ajax交上去,也可以做个表单直接交上去,也可以ajax直接交上去。 <div
class
=
"clear"
>
</div>