SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    645
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Make the selection selected?

    Now I have a drop down menu with 4 options.
    When someone make a selection they will reload the page and I want the dropdown to mark the selection they made to be selcted, but I don't know how to do it when reloading the same page.

    When the user select option1 in the dropdown they will go to index.php?page=1

    But how can I mark the dropdown so that it shows what the user selected?

  2. #2
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <select name="mypage">
    <?
    if($_GET[page]=="1")
    $Cmb1="selected";
    elseif(
    $_GET[page]=="2")
    $Cmb2="selected";
    elseif(
    $_GET[page]=="3")                                    
    $Cmb3="selected";
    ?>
    <option value="1" <?=$Cmb1?> >Option 1</option>
    <option value="2" <?=$Cmb2?> >Option 2</option>
    <option value="3" <?=$Cmb3?> >Option 3</option>
    </select>
    Try this
    Barbara


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
  •