1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!DOCTYPE HTML> <html> <head> <title>COMBO BOX</title> </head> <body> <form name="form_combo" action="combo_box.php" method="POST"> <br/><br/> <center> Option : <select name="option"> <option <?php if($option == 'Playing'){echo 'selected';} ?>>Playing</option> <option <?php if($option == 'Reading'){echo 'selected';} ?>>Reading</option> <option <?php if($option == 'Swimming'){echo 'selected';} ?>>Swimming</option> <option <?php if($option == 'Racing'){echo 'selected';} ?>>Racing</option> </select><br/><br/> <input name="submit" type="submit"/><br/><br/> <?php echo $option; ?> </center> </form> </body> </html> |
Kemudian untuk bagian PHP kodenya adalah sebagai berikut:
1 2 3 | <?php @$option = $_POST['option']; ?> |
Keseluruhan kodenya adalah sebagai berikut:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <?php @$option = $_POST['option']; ?> <!DOCTYPE HTML> <html> <head> <title>COMBO BOX</title> </head> <body> <form name="form_combo" action="combo_box.php" method="POST"> <br/><br/> <center> Option : <select name="option"> <option <?php if($option == 'Playing'){echo 'selected';} ?>>Playing</option> <option <?php if($option == 'Reading'){echo 'selected';} ?>>Reading</option> <option <?php if($option == 'Swimming'){echo 'selected';} ?>>Swimming</option> <option <?php if($option == 'Racing'){echo 'selected';} ?>>Racing</option> </select><br/><br/> <input name="submit" type="submit"/><br/><br/> <?php echo $option; ?> </center> </form> </body> </html> |
Tampilan akhirnya adalah sebagai berikut:
No comments:
Post a Comment