#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    9
    Rep Power
    0

    Select Selected on The Same Page


    Hello to all,
    I have create a form which has a dynamic dropdown list, that retrieves the list from a database. At the same page I have a table. When I select an option from the dropdown list and push the button "show" , the page refresh and the table fills with data. My problem is when the page refresh the dropdown doesn't hold my choice but return to the first choice. Is there any chance the dropdown list holds my choice when the page refresh to show the results to the table?
    Thank you all in advance for your answers and I'm sorry for my bad English.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,493
    Rep Power
    594
    You have to program it to set the 'selected' attribute on the choice when PHP re-sends the page.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    9
    Rep Power
    0
    Thank You For Your Answer. I'm new to php and I have no idea how to do that. Can you explain me how to do that? Thank you.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,493
    Rep Power
    594
    Presumably you have already identified the selection since you populate the table based on that. You are also outputting the select <option> tags somewhere. When you output the page, simply add selected to that <option> tag. This is really HTML not PHP.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo