tags:

views:

1746

answers:

2

Hi guys,

I have this struts tag:

<s:select name="country.id" 
list="countries"  
listValue="name" 
listKey="id"
headerValue="Select Country"
headerKey=""
label="Country" />

which outputs the following html code:

<select name="country.id" tabindex="12" id="registration_country">
    <option value="">Select Country</option>
    <option value="1">United States</option>
    <option value="2">Afghanistan</option>
    <option value="3">Albania</option>
    <option value="4">Algeria</option>
    ...
    <option value="192">Zambia</option>
    <option value="193">Zimbabwe</option>
</select>

How do I specify that I want, for example, "Albania" to be preselected in the list?

A: 

Try this:

headerKey="3"
Boris Pavlović
+2  A: 

Use the value attribute in the s:select tag:

<s:select name="country.id" 
list="countries"  
listValue="name" 
listKey="id"
headerValue="Select Country"
headerKey=""
label="Country"
value="3" />
Peter Hilton