SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing two values using one submit button

    I have two drop down menus (html forms). I would like a user to make a selection from each form, click a submit button and have both selected values passed to a php page for processing. This is my failed attempt:

    Code:
    <body>
    <form id="select_co" name="select_co" method="post" action="action.php">
     <select name="selected_co">
      <option selected="selected">Please select a County/City</option>
      <option value="1">A County</option>
      <option value="2">B County</option>
     </select>
     
    <select name="selected_sp">
      <option selected="selected">Please select a Species</option>
      <option value="33">caiman</option>
      <option value="55">gator</option>
     </select>
    <input name="" type="submit" />
    </form>
    The receiving php file:
    Code:
    <body>
    
    <?php 
    $selected_co;
    $selected_sp;
    
    
    echo $_POST['selected_co'];
    echo "<br />";
    echo $_POST['select_sp'];
    
    ?>
    </body>
    The selected_co value is passed, however the selected_sp value isn't. What am I doing wrong?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    name="selected_sp"
    $_POST['select_sp']

    Do you see the difference?

  3. #3
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good Grief ! I need to start drinking less (or perhaps more). Thank you my friend.


Bookmarks

Posting Permissions

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