js 数字相加 parseInt

<input   type="text"   id="a1"   value="1">   +     
  
<input   type="text"   id="a2"   value="1">   =     
  
<input   type="text"   id="a3"   readonly="true">   
  
<br>   
  
<input   type="button"   value="click"   onclick="foo()">   
  
<script>   
  
function   foo(){   
  a3.value   
=   parseInt(a1.value)   +   parseInt(a2.value);   
  }
   
  
</script>

posted on 2007-10-30 14:57  simhare  阅读(2935)  评论(1编辑  收藏  举报

导航