Results 1 to 2 of 2

Thread: validate a drop down menu

  1. #1
    Join Date
    Apr 2006

    validate a drop down menu

    i am having trouble validating my drop down menu when the method of the form which it is in is "post".
    my code is:
    <form action="add.php" method="post">
    $letter = array (1=> 'a','b','c','d','e','f' );
    echo '<select name="type">';
    echo '<option value="none"> - Choose - </option>';
    foreach($letter as $value1){
    echo "<option value=\"$value1\">$value1</option>\n";
    echo '</select>';

    now i want to validate this drop down menu so that if it shows ' - Choose -' when the form is submitted that there will be an error message saying 'please select a value'. can anyone help me with trying to validate this drop down?

  2. #2
    Join Date
    Jun 2004
    4846′36″ N 910′48″ E
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <style type="text/css">
    "<p>You choose: ".$_POST['type']."</p>";
    "<p>please select a value</p>";
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    = array (1=> 'a','b','c','d','e','f' );
    '<select name="type">';
    '<option> - Choose - </option>';
    $letter as $value1){
    "<option value=\"$value1\">$value1</option>\n";
    <input type="submit" value="submit">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles