SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast that_tim_fella's Avatar
    Join Date
    Feb 2003
    Location
    England
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select - ordering of options

    By default the code below will show the number 1 in the select box when I open the page that holds it.

    I'm wanting this page to open with a specific number displaying based on user input from the previous page. I can do this easily with a little php by re-ordering the options. So if the user has chosen 2, I can just write the options in the order 2,1,3. This is fine, but then the order of the numbers in the box is user-unfriendly.

    What I'd like to know is if there's a way to keep the order of the options but have whichever one I want to be displayed when the page opens.

    HTML Code:
    <select name='number'>
     <option>1
     <option>2
     <option>3
     </select>

  2. #2
    SitePoint Enthusiast that_tim_fella's Avatar
    Join Date
    Feb 2003
    Location
    England
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Feeling stupid now. Just add a selected argument to the option you want to show.

  3. #3
    SitePoint Addict DM3Dan's Avatar
    Join Date
    Sep 2004
    Location
    Albany, NY
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would you be gathering the info on the previous page? Like, through a form or something?

    You could most likely use PHP Sessions, but I wont even try to help you with that yet, as I am still learning my self. Here you can find the basics about sessions.

    Hope that helps .


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
  •