function s(){ 
var $ = document.form;
var count = document.form.gamount.value;
for (var i=1;i<count;i++){
var a = $.count_1_+i;
var b = $.prod_price_+i;
var c = $.cp3_+i;
var d = $.cp4_+i;
var e = $.sid_+i;
if(e.value=="1"){
c.value = 0;
d.value = Number(a.value)*Number(b.value);
}else{
c.value = Number(a.value)*Number(b.value);
d.value = 0;
}
}
}麻烦高手看一下上面的代码是什么问题?我为什么运行报错,执行不了!在线等!谢谢

解决方案 »

  1.   

    html文件?
    这样估计没人可以帮到你。
      

  2.   


    function s(){ 
    var $ = document.form;
    var count = document.form.gamount.value;
    for (var i=1;i<count;i++){
    var a = $.count_1_+i;
    var b = $.prod_price_+i;
    var c = $.cp3_+i;
    var d = $.cp4_+i;
    var e = $.sid_+i;
    if(e.value=="1"){
    c.value = 0;
    d.value = Number.valueOf(a.value)*Number.valueOf(b.value);
    }else{
    c.value = Number.valueOf(a.value)*Number.valueOf(b.value);
    d.value = 0;
    }
    }
    }
      

  3.   


    function s(){ 
    var $ = document.form;
    var count = document.form.gamount.value;
    for (var i=1;i<count;i++){
    var a = $.count_1_+i;
    var b = $.prod_price_+i;
    var c = $.cp3_+i;
    var d = $.cp4_+i;
    var e = $.sid_+i;
    if(e.value=="1"){
    c.value = 0;
    d.value = parseInt(a.value)*parseInt(b.value);
    }else{
    c.value = parseInt(a.value)*parseInt(b.value);
    d.value = 0;
    }
    }
    还不行就贴上你的完整代码
      

  4.   

    <script type="text/javascript"> 
    function s(){ 
    var $ = document.form;
    var count = document.form.gamount.value;
    for (var i=1;i<count;i++){
    var a = $.count_1_+i;
    var b = $.prod_price_+i;
    var c = $.cp3_+i;
    var d = $.cp4_+i;
    var e = $.sid_+i;
    if(e.value=="1"){
    c.value = 0;
    d.value = Number(a.value)*Number(b.value);
    }else{
    c.value = Number(a.value)*Number(b.value);
    d.value = 0;
    }
    }
    }
    </script>
    <%
    Set rsCheck=Server.CreateObject("ADODB.RecordSet") 
    strsql="select P_Sortid,P_gid,P_Name,P_Unit,P_Price,P_Price1,P_Price2 from Price where P_gid in ("&session("Prodid")&") "
    rsCheck.open strsql,conn,1,1
    %>
    <table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
                  <tbody><%
    Do While Not rsCheck.EOF
    dim sums
    sums=sums+1  '记录数
    %> 
      <tr bgcolor="#FFFFFF" onMouseOver="this.style.background='#EAF4FC';" onMouseOut="this.style.background='#FFFFFF';">
                    <td width="4%" height="25" align="center" class="bt2_top" title="序号:<%= sums %>"><input type="hidden" name="prod_id_<%=sums%>" value="<%=sums%>" /><%= sums %></td>
                    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
                    <td width="4%" align="center" class="bt2_top" title="操作"><input type="checkbox" name="ProdId" class="ProdId_ck" value="<%= rsCheck("P_gid") %>" /></td>
                    <td width="1" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
                    <td width="7%" align="center" class="bt2_top" title="编号:<%= rsCheck("P_gid") %>"><input type="hidden" name="prod_goodsid_<%=sums%>" value="<%=rsCheck("P_gid")%>" />&nbsp;<%=rsCheck("P_gid")%></td>
                    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
    <td width="20%" align="left" class="bt2_top" title="名称:<%= rsCheck("P_Name") %>"><input type="hidden" name="prod_goods_<%=sums%>" value="<%=rsCheck("P_Name")%>" />&nbsp;<%= rsCheck("P_Name") %></td>
                    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
    <td width="6%" align="center" class="bt2_top" title="请选择单位"><select name="prod_unit_<%=sums%>" class="Ssel2" id="prod_unit_<%=sums%>">
              <option value="<%= rsCheck("P_Unit") %>" selected="selected"><%= rsCheck("P_Unit") %></option>
              <option value="件">件</option>
      <option value="套">套</option>
      <option value="个">个</option>
      <option value="支">支</option>
      <option value="只">只</option>
      <option value="条">条</option>
      <option value="台">台</option>
      <option value="根">根</option>
      <option value="箱">箱</option>
      <option value="筒">筒</option>
      <option value="块">块</option>
      <option value="卷">卷</option>
      <option value="张">张</option>
      <option value="片">片</option></select></td>
                    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
    <td width="5%" align="center" class="bt2_top" title="数量"><input name="count_1_<%=sums%>" class="count" id="<%=sums%>" hang="<%=sums%>" lie="1" size="3" value="1" onChange="s()" /><input type="hidden" name="ct_<%=sums%>" class="zs" id="<%=sums%>" value="1" size="4" /></td>
                    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
    <td width="9%" align="center" class="bt2_top2" title="成本价:¥<%= rsCheck("P_Price") %>"><input type="hidden" name="prod_CjPrice_<%=sums%>" value="<%=rsCheck("P_Price")%>" />¥<%= rsCheck("P_Price") %></td>
                    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
                    <td width="9%" align="center" class="bt2_top" title="市场价:¥<%= rsCheck("P_Price1") %>">¥<%= rsCheck("P_Price1") %>&nbsp;</td>
                    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
                    <td width="9%" align="center" class="bt2_top" title="单价">¥<input class="price" name="prod_price_<%=sums%>" size="4" id="<%=sums%>" value="<%= rsCheck("P_Price1") %>" onChange="s()" />   <input type="hidden" class="price2" name="prod_price2_<%=sums%>" id="<%=sums%>" value="<%= rsCheck("P_Price2") %>" /></td>
    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
                    <td width="10%" align="center" bgcolor="#FFB8BF" class="bt2_top" title="金额">¥
                    <input name="cp_<%=sums%>" class="cp1" id="<%=sums%>" value="<%= round(rsCheck("P_Price1"),2) %>" size="6" readonly="readonly" />  <input type="hidden" name="cp2_<%=sums%>" class="cp2" id="<%=sums%>" value="<%= round(rsCheck("P_Price2"),2) %>" readonly="readonly" />
                    <input type="text" name="sid_<%=sums%>" class="sid" id="<%=sums%>" value="<%= rsCheck("P_Sortid") %>" readonly="readonly" />
                    <input type="text" name="cp3_<%=sums%>" class="cp3" id="<%=sums%>" value="<%if rsCheck("P_Sortid")=1 then%>0<%else%><%=rsCheck("P_Price1")%><%end if%>" readonly="readonly" />
                    <input type="text" name="cp4_<%=sums%>" class="cp4" id="<%=sums%>" value="<%if rsCheck("P_Sortid")=1 then%><%=rsCheck("P_Price1")%><%else%>0<%end if%>" readonly="readonly" /></td>
    <td width="1" align="center" class="bt2_top1"><img src="/yximg/blank.gif" /></td>
                    <td width="17%" align="center" class="bt2_top" title="备注"><input name="rm_<%=sums%>" class="linput1" id="rm_<%=sums%>" value="<% if rsCheck("P_Sortid")=17 then%>赠品,不保修!<%else%>保修一年!<%end if%>" maxlength="55" />
                    </td>
                  </tr><%
         rsCheck.MoveNext
         Loop
    rsCheck.close
    set rsCheck=nothing
    %>