かんたん作成.com【HTML,CSS,JavaScript,CGI,PHP】

Click Here! BB.excite
【BB.excite】Bフレッツ 工事費・接続料無料キャンペーン実施中!光ファイバー(Bフレッツ)の導入を検討しているお客様に朗報!Bフレッツ工事費・接続料無料!
Bfitセキュア
月額300円でSSLレンタルサーバーあなたのサイトの個人情報は、守られていますか?SSL通信(暗号化通信)を利用することで、あなたのサイトの個人情報を守ります。しかも、月額300円。
トラフィックゲート
ホームページ広告を載せて、おこづかいをゲットしよう!今なら、あなたの頑張りが形になる。ホームページをお持ちの方は必見!モバイル3キャリアにも完全対応!

電卓


<html>
<head>
<title>電卓</title>
   <script language="JavaScript">
   <!--
   disp   = "0";
   disp2   = "0";
   flag   = 0;
   function push(val) {
      if(val >= 0 && val <= 9) {         // 電卓に表示する数列を作成
         if(flag == 0) {
            disp   = val;
            disp2   = "0";
            flag   = 1;
         }
         else {
            disp   = disp + val;
            disp   = parseFloat(disp);
         }
      }
      else if(val == "C") {            // クリア
         disp   = "0";
         disp2   = "0";
         flag   = 0;
      }
      else {
         if(disp) {
            switch(flag) {         // 計算
            case 1:disp2 = parseFloat(disp2) + parseFloat(disp); break;
            case 2:disp2 = parseFloat(disp2) - parseFloat(disp); break;
            case 3:disp2 = parseFloat(disp2) * parseFloat(disp); break;
            case 4:disp2 = parseFloat(disp2) / parseFloat(disp); break;
            }
         }
         if(val == "=") {         // 計算方法を記憶
            flag   = 0;
            disp   = disp2;
         }
         else if(val == "+") {
            flag   = 1;
            disp   = "";
         }
         else if(val == "−") {
            flag   = 2;
            disp   = "";
         }
         else if(val == "×") {
            flag   = 3;
            disp   = "";
         }
         else if(val == "÷") {
            flag   = 4;
            disp   = "";
         }
      }
      document.form1.disp.value = disp      // 電卓に表示
   }
   //-->
   </script>
   <style>
   <!--
   input {
      width:   100%;
      height: 100%;
      font-size:   30px;
   }
   .disp {
      text-align:   right;
      font-size:   35px;
   }
   //-->
   </style>
</head>
<body>
<form name="form1" action="" method="">
<table width="250" height="250" border="1" bordercolor="#000000" cellspacing="0" cellpadding="0">
   <tr>
      <td colspan="4"><input type="text" name="disp" class="disp" value="0"></td>
   </tr>
   <tr>
      <td width="25%"><input type="button" value="7" onClick="push(this.value)"></td>
      <td width="25%"><input type="button" value="8" onClick="push(this.value)"></td>
      <td width="25%"><input type="button" value="9" onClick="push(this.value)"></td>
      <td width="25%"><input type="button" value="÷" onClick="push(this.value)"></td>
   </tr>
   <tr>
      <td><input type="button" value="4" onClick="push(this.value)"></td>
      <td><input type="button" value="5" onClick="push(this.value)"></td>
      <td><input type="button" value="6" onClick="push(this.value)"></td>
      <td><input type="button" value="×" onClick="push(this.value)"></td>
   </tr>
   <tr>
      <td><input type="button" value="1" onClick="push(this.value)"></td>
      <td><input type="button" value="2" onClick="push(this.value)"></td>
      <td><input type="button" value="3" onClick="push(this.value)"></td>
      <td><input type="button" value="−" onClick="push(this.value)"></td>
   </tr>
   <tr>
      <td><input type="button" value="0" onClick="push(this.value)"></td>
      <td><input type="button" value="C" onClick="push(this.value)"></td>
      <td><input type="button" value="=" onClick="push(this.value)"></td>
      <td><input type="button" value="+" onClick="push(this.value)"></td>
   </tr>
</table>
</form>
</body>
</html>
実行する
当サイトはリンクフリーです。
	<a href="http://www.kantansakusei.com/">かんたん作成.com【HTML,CSS,JavaScript,CGI,PHP】</a>