Showing correct option in select dropdown form element
Posted: 26 June 2008 02:37 AM   [ Ignore ]
Newbie
Rank
Total Posts:  24
Joined  2007-10-22

Hi there

I’m a happily using the User module (version 1.3.2), but am having problems showing a user’s details. Take the example below, and before anyone asks, the options are ‘Male’ and ‘Female’ and not ‘Thanks’ and ‘No thanks!’.

<select name="user_sex">
 
{select_user_sex}
 
<option value="{value}">{value}</option>
 
{/select_user_sex}
</select>

How do I get this to show what a user has previously selected?

Thanks in advance,

Jim

Profile
 
 
Posted: 26 June 2008 06:12 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3232
Joined  2006-10-18
sixmedia - 26 June 2008 02:37 AM

I’m a happily using the User module (version 1.3.2), but am having problems showing a user’s details. Take the example below, and before anyone asks, the options are ‘Male’ and ‘Female’ and not ‘Thanks’ and ‘No thanks!’.

Hahaha!! Thanks for the clarification LOL

sixmedia - 26 June 2008 02:37 AM

<select name="user_sex">
 
{select_user_sex}
 
<option value="{value}">{value}</option>
 
{/select_user_sex}
</select>


How do I get this to show what a user has previously selected?

I’m assuming you’re using this code on the User:Edit page template…
You’re almost there… just missing the {selected} wink

<select name="user_sex">
 
{select_user_sex}
 
<option value="{value}" {selected}>{value}</option>
 
{/select_user_sex}
</select>

 Signature 
Profile
 
 
Posted: 26 June 2008 10:09 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  24
Joined  2007-10-22

Wow! That was dead easy - thanks Pie Man grin

Profile