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
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    68
    Thanks
    29
    Thanked 0 Times in 0 Posts

    how to set default value on form drop downs

    I have a form with select drop down options. The form allows users to edit their profile, so I want to dynamically set the default value equal to their value in the database. I have the database part working but I'm having problems figuring out the html part for some reason.

    What should I have for the first line where %s is their current value.

    [HTML]
    <option value='%s' selected='selected'>%s</option>
    [/HTML]

    Here is the select tag
    [HTML]
    <select name='state'>
    <option value='%s' selected='selected'>%s</option>
    <option value='Alabama'>Alabama</option>
    <option value='Alaska'>Alaska</option>
    <option value='Arizona'>Arizona</option>
    <option value='Arkansas'>Arkansas</option>
    <option value='California'>California</option>
    <option value='Colorado'>Colorado</option>
    <option value='Connecticut'>Connecticut</option>
    <option value='Delaware'>Delaware</option>
    <option value='District Of Columbia'>District Of Columbia</option>
    <option value='Florida'>Florida</option>
    <option value='Georgia'>Georgia</option>
    <option value='Hawaii'>Hawaii</option>
    <option value='Idaho'>Idaho</option>
    <option value='Illinois'>Illinois</option>
    <option value='Indiana'>Indiana</option>
    <option value='Iowa'>Iowa</option>
    <option value='Kansas'>Kansas</option>
    <option value='Kentucky'>Kentucky</option>
    <option value='Louisiana'>Louisiana</option>
    <option value='Maine'>Maine</option>
    <option value='Maryland'>Maryland</option>
    <option value='Massachusetts'>Massachusetts</option>
    <option value='Michigan'>Michigan</option>
    <option value='Minnesota'>Minnesota</option>
    <option value='Mississippi'>Mississippi</option>
    <option value='Missouri'>Missouri</option>
    <option value='Montana'>Montana</option>
    <option value='Nebraska'>Nebraska</option>
    <option value='Nevada'>Nevada</option>
    <option value='New Hampshire'>New Hampshire</option>
    <option value='New Jersey'>New Jersey</option>
    <option value='New Mexico'>New Mexico</option>
    <option value='New York'>New York</option>
    <option value='North Carolina'>North Carolina</option>
    <option value='North Dakota'>North Dakota</option>
    <option value='Ohio'>Ohio</option>
    <option value='Oklahoma'>Oklahoma</option>
    <option value='Oregon'>Oregon</option>
    <option value='Pennsylvania'>Pennsylvania</option>
    <option value='Rhode Island'>Rhode Island</option>
    <option value='South Carolina'>South Carolina</option>
    <option value='South Dakota'>South Dakota</option>
    <option value='Tennessee'>Tennessee</option>
    <option value='Texas'>Texas</option>
    <option value='Utah'>Utah</option>
    <option value='Vermont'>Vermont</option>
    <option value='Virginia'>Virginia</option>
    <option value='Washington'>Washington</option>
    <option value='West Virginia'>West Virginia</option>
    <option value='Wisconsin'>Wisconsin</option>
    <option value='Wyoming'>Wyoming</option>
    </select>
    [/HTML]

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    This is a PHP related question, so post your PHP code of that page.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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