注册 登录
编程论坛 ASP技术论坛

为什么这段代码不能实现 数量×单价=总额 啊?

hhh361 发布于 2008-02-01 23:40, 820 次点击
高手请帮帮忙~~
为什么这段代码不能实现 数量×单价=总额 啊?

<table>
   
    <tr bgcolor="ECF5FF">
      <td>订货数量:</td>
      <td><input name="h_num" type="text" id="h_num" onBlur="add()" value="0" size="5">
        件 </td>
      <td>货物单价:</td>
      <td><input name="h_price" type="text" id="h_price" onBlur="add()" value="0" size="5">
        元 </td>
      <td>总额:</td>
      <td><div align="right">数量 * 单价 =</div></td>  
      <td colspan="2"><input name="h_count_price" type="text" id="h_count_price2" value="0" size="5" readonly>
        元</td>  
    </tr>
    <script   language="javascript">  
  function   add(){  
  document.myform.h_count_price.value   =   Number(document.myform.h_num.value)   *   Number(document.myform.h_price.value)  
  
  }  
  </script>
1 回复
#2
madpbpl2008-02-01 23:47
<table>
   
    <tr bgcolor="ECF5FF">
      <td>订货数量:</td>
      <td><input name="h_num" type="text" id="h_num" onBlur="add()" value="0" size="5">
        件 </td>
      <td>货物单价:</td>
      <td><input name="h_price" type="text" id="h_price" onBlur="add()" value="0" size="5">
        元 </td>
      <td>总额:</td>
      <td><div align="right">数量 * 单价 =</div></td>  
      <td colspan="2"><input name="h_count_price" type="text" id="h_count_price2" value="0" size="5" readonly>
        元</td>  
    </tr>
    <script   language="javascript">  
  function   add(){  
  document.getElementById("h_count_price").value   =   parseInt(document.getElementById("h_num").value)   *   parseInt

(document.getElementById("h_price").value)  
  
  }  
  </script>
1