圓柱模板計算器V1.0

    因很多客戶需求,就做了一個初始版本的產品圓柱模板面積和價格的計算器,界面非常簡單,做工粗糙,但是功能是可以運行。後期會在界面和功能上進行升級,打算出一個微信小程序版本。這個程序僅供參考。

     演示地址:http://zhimo.yuanzhumuban.cc/jisuanqi/

    

<?php
 /*
    開發者:支模網(zhimo.yuanzhumuban.cc)
    開發日期:2018-08-20
    功能:圓柱模板價格計算器
 */
function calculate() {
    //判斷是否接收到
    if($_POST['in1'] != "" && $_POST['in2'] != "") {
         
        //判斷接收到的是否爲數字
        if(is_numeric($_POST['in1']) && is_numeric($_POST['in2'])) {
            $s1 = $_POST['in1'];//高度
            $s2 = $_POST['in2'];//直徑
            $s3 = $_POST['in3'];//數量
            $end = $_POST['operator'];//判斷價格是否含稅的價格
            $result = "";//輸出結果
        
            //進行判斷是否含稅
            switch($end){
                case "125":
                    $mianji=3.14*$s1*$s2;
                    $result = (3.14*$s1*$s2)*125*$s3;
                    break;
                case "132":
                   $mianji=3.14*$s1*$s2;
                   $result = (3.14*$s1*$s2)*132*$s3;
                    break;
            }  
        }
        else{
          $result = "輸入的字符必須爲數字";
        }
    }
    else{
       $result = "都不能爲空哦";  
    }
return $result;
}
//面積計算
function mianji() {
    //判斷是否接收到
    if($_POST['in1'] != "" && $_POST['in2'] != "") {
         
        //判斷接收到的是否爲數字
        if(is_numeric($_POST['in1']) && is_numeric($_POST['in2'])) {
            $s1 = $_POST['in1'];//高度
            $s2 = $_POST['in2'];//直徑
            $s3 = $_POST['in3'];//數量
            $end = $_POST['operator'];//判斷價格是否含稅的價格
            $result = "";//輸出結果
        
            //進行判斷是否含稅
            switch($end){
                case "125":
                    $result=3.14*$s1*$s2*$s3;
                    break;
                case "132":
                   $result=3.14*$s1*$s2*$s3;
                    break;
            }  
        }
        else{
          $result = "輸入的字符必須爲數字";
        }
    }
    else{
       $result = "都不能爲空哦";  
    }
return $result;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>圓柱模板價格計算器</title>
 <meta name="keywords" content="圓柱模板面積計算,圓柱模板價格計算">
<meta name="description" content="圓柱模板面積怎麼算?使用圓柱模板面積及價格在線計算器,輸入圓柱模板直徑、高度、單價、數量即可得出總價">
<link type="text/css" rel="stylesheet" href="style.css" />
<script type="text/javascript" src="cal.js"></script>
</head>
<body>
       <div id="wrap">
           <h1>圓柱模板價格計算器</h1>
           <form action="index.php" method="post" onsubmit="return check(this);">
               <table>
                   <tr>
                       <td>高度:</td>
                       <td><input type="text" name="in1" value="<?php echo $_POST['in1'] ?>" />米</td>
                   </tr>
                   <tr>
                       <td>直徑:</td>
                       <td><input type="text" name="in2" value="<?php echo $_POST['in2'] ?>" />米</td>
                   </tr>
                   <tr>
                       <td>數量:</td>
                       <td><input type="text" name="in3" value="<?php echo $_POST['in3'] ?>" />棵</td>
                   </tr>
                   <tr>
                       <td>價格:</td>
                       <td>
                           <select name="operator">
                               <option value="125" <?php if($_POST['operator'] == "125") echo "selected";?>>125元</option>
                               <option value="132" <?php if($_POST['operator'] == "132") echo "selected";?>>132元(含稅)</option>
                           </select>
                       </td>
                   </tr>
                   <tr>
                       <td>
                           <input class="s" type="submit" value="計算" />
                       </td>
                       <td>
                           <input class="s" type="reset" value="重置" />
                       </td>
                   </tr>
                        <tr>
                              <td>計算結果爲:</td>
                              <td>
                                   <input type="text" class="r" value="<?php echo calculate() ."元"?>   <?php echo mianji() ."平方米"?>" />
                              </td>
                         </tr>
                 </table>
          </form>
        </div>           
        <div id="footer">
            <span>Copyright © 2018-08-20  鵬程<a href="http://zhimo.yuanzhumuban.cc/">圓柱模板</a>技術支持</span>
        </div>
</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章