网页计算器(javascript脚本)

<html>
   <head>
      <script>
          var  s="";
          function add(a)//连接输入字符
             {
                 var t;
                 t=a.value;
                 s+=t;
                 cal.sr.value=s;
             }
          function rn()//计算
             {
                 cal.rs.value=eval(s);
             }
      </script> 
   </head>
   <body>
      <center>
      <form name="cal">
          <input type="text"  style="{font-size:40px}" name="sr" value="" size=16> <br>
          <input typt="text"  style="{font-size:40px}" name="rs" value="" size=16> <br>
          <input type="button" value="7" name="b7" οnclick="add(this)">
          <input type="button" value="8" name="b8" οnclick="add(this)">
          <input type="button" value="9" name="b9" οnclick="add(this)">
          <input type="button" value="+" name="bjia" οnclick="add(this)"> <br>
          <input type="button" value="4" name="b4" οnclick="add(this)">
          <input type="button" value="5" name="b5" οnclick="add(this)">
          <input type="button" value="6" name="b6" οnclick="add(this)">
          <input type="button" value="-" name="bjian" οnclick="add(this)"> <br>
          <input type="button" value="1" name="b1" οnclick="add(this)">
          <input type="button" value="2" name="b2" οnclick="add(this)">
          <input type="button" value="3" name="b3" οnclick="add(this)">
          <input type="button" value="*" name="bcheng" οnclick="add(this)"> <br>
          <input type="button" value="." name="bdian" οnclick="add(this)">
          <input type="submit" value="C" name="del">
          <input type="button" value="=" name="bd" οnclick="rn()">
          <input type="button" value="/" name="bchu" οnclick="add(this)"> <br>
      </form>
      </center>
   </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值