js自动计算问题,高分请大侠们帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/25 17:26:32
本人菜鸟,做了个小东西,想实现功能,对每个员工进行月度考核,遇到的问题,二级分类的分和大类分不知道怎么用JS 自动添加上?
具体代码如下:
<HTML>
<HEAD>
<title><%=Application("P_webName")%></title>
<LINK REL="stylesheet" HREF="<%=Application("P_cssPath")%>" TYPE="text/css">
<script src="<%=Application("P_jsPath")%>"></script>
<SCRIPT>
function addValue(v)
{
var bi= document.getElementById("zongfen");
var a = bi.value;
if(a=="")
{
a=0;
}
if(v=="")
{
v=0;
}
bi.value=parseInt(a) + parseInt(v);
}
</SCRIPT>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD>
<BODY bgcolor="<%=C_Color0%>" style="SCROLLBAR-HIGHLIGHT-COLOR:<%=C_Color4%>;SCROLLBAR-SHADOW-COLOR:<%=C_Co

这样岂不是每次失去焦点总分都累加?
=========================================
没装ISS,囧。临时写了个只有JS的,希望对你有帮助。
小类1-1<input name="s1" onblur="ct(this.name,0);"><br>
小类1-2<input name="s1" onblur="ct(this.name,0);"><br>
大类1<input name="sort" value="0" disabled><br>
小类2-1<input name="s2" onblur="ct(this.name,1);"><br>
小类2-2<input name="s2" onblur="ct(this.name,1);"><br>
大类2<input name="sort" value="0" disabled><br>
总<input id="total" value="0" disabled><br>
<script>
function ct(v,s){//s为第几个大类,编号从asp里获得写到input的onblur事件里,从0开始计数。
a = document.getElementsByName(v);
b = document.getElementsByName("sort");
tmp=0;
for(i=0;i<a.length;i++){
if(a[i].value) tmp+=parseInt(a[i].value);