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.

<option value='%s' selected='selected'>%s</option>

Here is the select tag

                   <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>

Well it not the HTML it’s the thinking behind it. You DONT want to have a separate option tag for this. Even if it worked it would mean you would have the users location appear TWICE ( once as the selected and the other in the list).

What you want to do instead is ADD “selected=‘selected’” to the option tag that has the same value as the users current value.

Are you using PHP to pull the data or doing an AJAX call? Have to know what your using on the server side to help.

Yeah your thinking about this the wrong way, add “selected=‘selected’” to the option tag that matches the users selected value.