Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts

    why I cant post or get the value of the select box that i choose when click button

    why I cant post or get the value of the select box that i choose when click button.

    Heres my code.

    PHP Code:
    <form name="adfdf" method="post">
    <select name="clientss">
    <? 
    while($crow=mysql_fetch_array($qresults)){
      if(
    $_GET['clientss']==$crow[employer_name]- $crow[employer_id])
    echo 
    "<option value=$crow[employer_name]- $crow[employer_id] selected>$crow[employer_name]</option>";
    else
    echo 
    "<option value=$crow[employer_name]- $crow[employer_id]>$crow[employer_name]</option>";    
    }
    ?>
    </select>

    <tr><td colspan="2"><input type="submit" name="go" value="Show Report"></td></tr>
    </form>

    if(isset($_POST['go'])) {
    $clientss=$_POST['clientss'];

    echo $clientss ----------- I wish to get the value of the select box when clicking the submit button
    }
    thanksss

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Maybe you need a refresher on how PHP deals with forms?

    http://www.php.net/manual/en/tutorial.forms.php

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Location
    D0u$h!t3 k4?
    Posts
    512
    Thanks
    2
    Thanked 5 Times in 5 Posts
    I believe your problem is that the form needs an action set. That is, you aren't telling it where to post the data to. Also, you are checking for a GET when you are actually POSTing.
    PHP Code:
    $hello file_get_contents('hello.txt'); echo $hello
    hello

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    While you should always set an action, if you don't the form posts to its own page.


  •  

    Posting Permissions

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