一个自己写的网页计算器

    <style type="text/css">

.style1{
    width:60px;
    height:60px;
    text-align:center;
}
.style2{
        border-style: inset;
        width: 340px;
        height:40px;
        cursor: auto;/*光标属性*/
        top: 0px;
        left: 243px;
        overflow:auto;  /*overflow 属性规定如何处理如何处理不符合元素框的内容。*/
        resize:none;
        overflow-x:hidden;
        overflow-y:hidden
}
.style3{
     /*text-align:"center";*/
     border:1px red solid";
     width:300px;
     height:240px;
}
.style3 input{
    height:59px;
    width:59px;
}
.style4{
    background-image:url(a.jpg);
    text-align:center;
    margin:0 auto;
    background-color:gray;
    width:360px;
}
#Buttonjia{
    height:120px;
    width:59px;
}

</style>
<script>
var valueone="";
function Button_click(valuetwo){
  valueone=valueone+valuetwo;
  document.getElementById("text").value=valueone;
  return true;
  }
 function Calculate(valuethree){
 try{
    document.getElementById("text").value=valueone+valuethree+eval(document.getElementById("text").value);
 }catch (excp) {

        document.getElementById("text").innerHTML = "<font color=\"red\">您输入的表达式有错误,请检查后重新计算!!!!</font>";

    }

 return true;
 }
 function Removeall() {
    valueone= "";
    document.getElementById("text").innerHTML = "";
    return true;
}
var oLink = document.createElement("");
    oLink.href = "#";
</script>

 <div class="style4" >   
     <form >
     <div align=center>
      <textarea class="style2" id="text" name="text01" readonly="readonly"style="font-size:30px;margin:6px auto 2px auto;" ></textarea>
     </div>
      <table class="style3" align=center>
       <tr>
          <td class="style1"><input id="Button1" type="button" value="1"onclick="return Button_click('1')" /></td>
          <td class="style1"><input id="Button2" type="button" value="2"onclick="return Button_click('2')" /></td>
          <td class="style1"><input id="Button3" type="button" value="3"onclick="return Button_click('3')" /></td>
          <td class="style1"><input id="Button(" type="button" value="("onclick="return Button_click('(')" /></td>
          <td class="style1"><input id="Button)" type="button" value=")"onclick="return Button_click(')')" /></td>
       </tr>
       <tr>
          <td class="style1"><input id="Button4" type="button" value="4"onclick="return Button_click('4')" /></td>
          <td class="style1"><input id="Button5" type="button" value="5"onclick="return Button_click('5')" /></td>
          <td class="style1"><input id="Button6" type="button" value="6"onclick="return Button_click('6')" /></td>
          <td class="style1"><input id="Button*" type="button" value="*"onclick="return Button_click('*')" /></td>
          <td class="style1"><input id="Button/" type="button" value="/"onclick="return Button_click('/')" /></td>
       </tr>
       <tr>
          <td class="style1"><input id="Button7" type="button" value="7"onclick="return Button_click('7')" /></td>
          <td class="style1"><input id="Button8" type="button" value="8" onclick="return Button_click('8')" /></td>
          <td class="style1"><input id="Button9" type="button" value="9" onclick="return Button_click('9')" /></td>
          <td rowspan=2 class="style1"><input id="Buttonjia" type="button" value="+" onclick="return Button_click('+')"/></td>
          <td class="style1"><input id="Button-" type="button" value="-" onclick="return Button_click('-')" /></td>
       </tr>
       <tr>
          <td class="style1"><input id="reset01" type="reset" value="重置"onclick="return Removeall()" /></td>
          <td class="style1"><input id="Button00" type="button" value="0"onclick="return Button_click('0')" /></td>
          <td class="style1"><input id="Button." type="button" value="." onclick="return Button_click('.')" /></td>
          <td class="style1"><input id="Button=" type="button" value="=" onclick="return Calculate('=')" /> </td>
       </tr>  
      </table>
    </form>
    </div>
 

 

个人博客源地址:http://qtbk.xyz/?p=151

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值