| 第10週 checkbox 與 select<?php $command=$_POST["command"]; if ($command==null) { echo("<html> <body> <center> <form method=post action=$SELF_PHP> 選項: <p> <input type=checkbox name=choice[] value=1>choice 1 <p> <input type=checkbox name=choice[] value=2>choice 2 <p> <input type=checkbox name=choice[] value=3>choice 3 <p> <input type=checkbox name=choice[] value=4>choice 4 <p> <input type=checkbox name=choice[] value=5>choice 5 <p> <input type=submit name=command value=送出> <input type=reset name=command value=清除> </form> </center> </body> </html>"); } if ($command=="送出") { $choice=$_POST["choice"]; foreach ($choice as $number) $result=$result.$number; echo("<html> <body> <center> 選項:$result <p> </center> </body> </html>"); } ?>
<?php $command=$_POST["command"]; if ($command==null) { echo("<html> <body> <center> <form method=post action=$SELF_PHP> 月 <select name=month size=1> "); for ($i=1; $i<=12; $i++) echo("<option value=$i>$i </option>"); echo("</select> <p> 日 <select name=day size=1> "); for ($i=1; $i<=31; $i++) echo("<option value=$i>$i </option>"); echo("</select> <p>"); echo("<input type=submit name=command value=送出> <input type=reset name=command value=清除> </form> </center> </body> </html>"); } if ($command=="送出") { $month=$_POST["month"]; $day=$_POST["day"]; echo("<html> <body> <center> $month 月 $day 日 <p> </center> </body> </html>"); } ?>
作業: 寫一程式 第一個頁面顯示登入頁面(帳號密碼), 以學號為帳號密碼,登入成功後顯示第二頁面 利用兩種 標簽 checkbox 與 select, checkbox可以多重選擇各人嗜好(至少列出5種) select 可以選擇出生年 月 日 第三個頁面顯示結果
| |