Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Thanked 2 Times in 2 Posts

    Editing User Info

    Here's a question what if I have an edit script that gets the users info and in that form has a drop down select menu. How do I get it to have the current value they are already selected?

    PHP Code:
    print '<tr>';
    '<td class=rowheading>Account:</td>';
    '<td class=row3><select name=enabled class=selection>';
    '<option value=1>Enabled<option value=0>Disabled</option>';

  2. #2
    Regular Coder Common's Avatar
    Join Date
    Jan 2009
    Glasgow, UK
    Thanked 13 Times in 13 Posts
    If you put selected="selected" into the <option> tag that'll do as you ask. As for implementing, a simple:

    if($current_info == "this"){
    echo "<option value=\"selected\">";

    kinda thing would do, you could put it in a function then wrap it round each one. I'm sure there'll be a more efficient (probably involving loops...) method, but this is how I do it.

    Edit: Btw, in case you didn't notice you'll need a </option> after "Enabled".


Posting Permissions

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