<select name="state" class="input-small" selected="<? if(isset($_SESSION['user'])){ echo $row_login['state']; }?>">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
I am creating a user profile edit section and need the users pre-selected state to show up as the list default. How can I manage to do this?
Preferably something that doesnt involve jquery because it seems like there should be a simple solution to this problem. Thanks!
Just replace your options list with the above, it will dynamically create the list then and when printing out each option will check to see if that state option is the one the user has. If it is then it will select that as the default. A lot easier than having to do an if() statement 50 times.