Generating a dynamic pull-down menu : Form Select « Form « PHP






Generating a dynamic pull-down menu

 
<?
if ($site != "") :
    header("Location: http://$site");
    exit;
else :
?>

<html>
<head>
<title></title>
</head>
<body>
<?
$favsites = array ("www.java2s.com","www.yahoo.com","www.ms.com","www.php.com");

?>
<form action = "index.php" method="post">
<select name="site">
<option value = "">Choose a site:
<?
$x = 0;

while ( $x < sizeof ($favsites) ) :
          print "<option value='$favsites[$x]'>$favsites[$x]";
          $x++;
endwhile;
?>
</select>
<input type="submit" value="go!">
</form>
<?
endif;
?>
  
  








Related examples in the same category

1.Form select input
2.An HTML Form Including a SELECT Element
3.A
4.A day choice
5.An HTML Form with a select Element
6.Validating a drop-down menu with in_array()
7.Displaying a
8.Setting a default value in a
9.Setting defaults in a multi-valued
10.Creating Form Elements Based on the Current Time and/or Date
11.Creating Form Elements with Multiple Options
12.One choice for each day from 1 to 31
13.One choice for each year from last year to five years from now