溫瑞烘老師的教學歷程檔案(Teaching ePortfolio) - PHP教學 - Type=Radio應用範例
 

資訊管理系
副教授
温瑞烘


歷程檔案 Portfolio


關於我 About Me

Type=Radio應用範例

<?php
 $command=$_POST["command"];
 if ($command==null)
  {
   echo("<html>
         <body>
         <center>
         <form method=post action=$SELF_PHP>
         <p>
         數目一
         <input type=text name=num1 size=5>
         &nbsp; &nbsp; &nbsp;
         <input type=radio name=choice value='+'>+
         &nbsp; &nbsp;
         <input type=radio name=choice value='-'>-
         &nbsp; &nbsp;
         <input type=radio name=choice value='*'>*
         &nbsp; &nbsp;
         <input type=radio name=choice value='/'>/
         &nbsp; &nbsp; &nbsp;
         數目二
         <input type=text name=num2 size=5><p>
         <input type=submit name=command value=送出>
         <input type=reset  name=command value=清除>
         </form>
         </center>
        </body>
        </html>");

  }
if ($command=="送出")
 {
  $num1=$_POST["num1"];
  $choice=$_POST["choice"];
  $num2=$_POST["num2"];
  switch ($choice)
   {
    case "+" : $result=$num1+$num2; $plus ="checked"; break;
    case "-" : $result=$num1-$num2; $minus="checked"; break;
    case "*" : $result=$num1*$num2; $times="checked"; break;
    case "/" : $result=$num1/$num2; $div  ="checked"; break;
   }
   echo("<html>
         <body>
         <center>
         結果=$result
         </center>
        </body>
        </html>");

 }
?>

全部共 0則留言
登入帳號密碼代表遵守學術網路規範
 


文章分類 Labels

 


最新文章 Top10

中華科技大學數位化學習歷程 - 意見反應