Klaus Hartl schrieb:
> Arne-Kolja Bachstein schrieb:
>
>> Hi,
>>
>> does anyone know how I can set the selected option in an option list?
>> I got several dropdowns to select a date and would like to preselect the
>> current date using JS (cannot use a server side language atm). I know
>> how to find out the date, but how could I (easily) select the
>> corresponding option?
>>
>> Greets,
>>
>> Arne
>> http://www.arnekolja.com
>>
>
>
> If for example your option values would look like "02/21/2007" etc. you
> could easily set the selected one with:
>
> $('#date').val('02/22/2007');
>
>
> <select id="date">
> ...
> <option value="02/21/2007">02/21/2007</option>
> ...
> </select>
>
Or, in case you have seperated selects for each value:
$("#year option:contains(2007)").attr("selected", true);
--
Jörn Zaefferer
http://bassistance.de
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/