var lang = 'fra';
$('#lang option[value=' + lang + ']').attr('selected', 'selected');

or

var lang = 'deu';
$('#lang').val(lang);

- Richard

On Sat, Dec 19, 2009 at 3:35 PM, Andre Polykanine <an...@oire.org> wrote:

> Hello Richard and all,
>
> Yepp, it works)
> and if I want to do the same with a select box?
> <select id="lang">
> <option value="enu">English</option>
> <option value="fra">French</option>
> <option value="deu">German</option>
> Say, I have it previously set to French.
>                                Do I need to make a loop or I can do
>                                it in the same simple way?
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> Twitter: m_elensule
>
> ----- Original message -----
> From: Richard D. Worth <rdwo...@gmail.com>
> To: jquery-en@googlegroups.com <jquery-en@googlegroups.com>
> Date: Saturday, December 19, 2009, 10:24:40 PM
> Subject: [jQuery] To make an Id using a variable
>
> $("#utype" + t)
>
> - Richard
>
> On Sat, Dec 19, 2009 at 3:18 PM, Andre Polykanine <an...@oire.org> wrote:
>
> > Hello everyone,
> > What I'm trying to do is to make a radio button checked depending on a
> > variable gotten via PHP.
> > Here's the code:
> > // What radio button was checked previously?
> > var t=<?=$f[Type]?>;
> > // Say it was 2. Then the id must be #utype2
> > $("#'utype'+t").attr("checked", "checked");
> >
> > What am I doing wrong?
> > Maybe there's a way to do the same using the Value attribute of the
> > input tag?
> >
> > --
> > With best regards from Ukraine,
> > Andre
> > Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> > jabber.org
> > Yahoo! messenger: andre.polykanine; ICQ: 191749952
> > Twitter: m_elensule
> >
> >
>
>

Reply via email to