<table width="407" border="0" align="left" cellpadding="0" cellspacing="1" class="tb" id="tlist">
              <tr class="tit2">
                <td width="149">产品型号</td>
                <td width="81">数量</td>
                <td width="81">单价</td>
                <td width="122" colspan="2">小计</td>
                </tr>
              <tr class="tit2">
                <td colspan="5"><%
sql="select * from thjl where thd='"&request("thd")&"' and id in(select max(id) from thjl group by fno)"
set rs_buy2=conn.execute(sql)
  %><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <%x=0
do while rs_buy2.eof=false

%> <tr class="tit3">
                    <td width="34%"><input name='fno' type='text' value="<%=rs_buy2("fno")%>" size='15'></td>
                    <%dim xx1,xx2,xx3
 set rs_kc=conn.execute("select iif(IsNull(sum(fqty)), 0, sum(fqty))  as zs from thjl where fno='"&rs_buy2("fno")&"'")
xx1=rs_kc("zs")
%><td width="19%"><input type='text' name='fqty' size='8' value='<%=xx1%>' onchange='chtotal( this ,<%=x%>);'></td>
                    <td width="19%"><input type='text' name='fprice' size='8' value='0' onchange='chtotal( this ,<%=x%>);'></td>
                    <td width="28%"><input type='text' name='ftotal' value='0' size='12' readonly ></td>
                  </tr><%
rs_buy2.movenext
x=x+1
loop

rs_kc.close
    set rs_kc=nothing
%>
                </table></td>
                </tr>
                        <tr class="tit3">
                <td colspan=7 align='center'>   <script language="javascript" src="main.js"></script>
                <script language="javascript" src="editor.js"></script>            </td>
              </tr>
            </table></td>
          </tr>
          <tr class="tit3">
            <td width="9%">合计金额</td>
            <td width="91%" colspan=6><input type='text' name='faccount' id='znum' value='0' size=20></td>
          </tr>
        </table>       从数据库读数据到相应的表单当中,然后要把各个行的产品的数量(fpty)*单价(fprice)=小计(ftotal)    然后个 小计相加自动计算到合计金额(faccount)
这个用js怎么实现