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 2 of 2

Thread: select by GET

  1. #1
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts

    select by GET

    Hi, what is proper way to auto select one
    of these below based on a GET value?

    PHP Code:
    $sel = $_GET['country'];

    <TD>
    <SELECT NAME="LOCATION">
    <OPTION VALUE="<?php $sel ?>">
    <OPTION VALUE="Austria">Austria
    <OPTION VALUE="Denmark">Denmark
    <OPTION VALUE="Germany">Germany
    </SELECT>
    </TD>
    Thanks
    Sonny

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,301
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    <OPTION VALUE="<?php $sel ?>" selected="selected">

    No I don't know why selected is not true/false and is the same value as its name.. it's daft if you ask me.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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